View Full Version : Looking for MAXScript/SDK methods handling mouse interaction
06-03-2008, 11:44 AM
Such as when the cursor hits the side of the main window at a certain speed, hide or bring out the Command Panel. Just like what software? Forget, a video composition one.
06-03-2008, 12:17 PM
well, this ignores the mouse speed; but you could determine that by taking the mouse's position at two of the intervals and then check if the speed was great enough or not.
This just opens/closes the command panel based on where the mouse is within the 3ds Max window. If it's within 16 pixels of the right border, it will open the command panel - if it's not already open. Otherwise, if the command panel is open, it will check if the mouse is still within the command panel area (single column, about 192 pixels).. if it's not, it closes the command panel. If the mouse goes outside the max window, it does nothing.
There's a small rollout that shows all the variables involved.
rollout test "Test" width:304 height:248 (
label lbl_maxpos_lbl "getMaxWindowPos()" pos:[8,8] width:288 height:16
label lbl_maxpos "" pos:[16,24] width:280 height:16
label lbl_maxstate_lbl "max state" pos:[8,40] width:288 height:16
label lbl_maxstate "" pos:[16,56] width:280 height:16
label lbl_maxsize_lbl "getMaxWindowSize()" pos:[8,88] width:288 height:16
label lbl_maxsize "" pos:[16,104] width:280 height:16
label lbl_rightedge_lbl "right edge (pos.x+size.x)" pos:[8,128] width:288 height:16
label lbl_rightedge "" pos:[16,144] width:280 height:16
label lbl_mousepos_lbl "mouse pos" pos:[8,168] width:288 height:16
label lbl_mousepos "" pos:[16,184] width:280 height:16
label lbl_mousestate_lbl "mouse edge state" pos:[8,208] width:288 height:16
label lbl_mousestate "" pos:[16,224] width:280 height:16
Timer tick_tock "" pos:[13,245] width:24 height:24 interval:100 active:true
local edgeWidth = 16
on tick_tock tick do (
maxPos = getMaxWindowPos()
lbl_maxpos.text = maxPos as string
if (maxPos == [-4,-4]) then (
maxPos = [0,0]
lbl_maxstate.text = "maximized"
else ( lbl_maxstate.text = "windowed" )
maxSize = getMaxWindowSize()
lbl_maxsize.text = maxSize as string
rightEdge = maxPos.x + maxSize.x
lbl_rightedge.text = "[" + rightEdge as string + ",*]"
mousePos = mouse.screenPos
lbl_mousepos.text = mousePos as string
if (contains (Box2 maxPos.x maxPos.y maxSize.x maxSize.y) mousePos) then (
if ((rightEdge - mousePos.x) < edgeWidth) then (
if (not cui.commandPanelOpen) then (
lbl_mousestate.text = "inside max, at edge, opening CMDpanel"
cui.commandPanelOpen = true
lbl_mousestate.text = "inside max, at edge"
if (cui.commandPanelOpen) then (
if ((rightEdge - mousePos.x) > 192) then (
lbl_mousestate.text = "inside max, outside CMDpanel, closing CMDpanel"
cui.commandPanelOpen = false
else ( lbl_mousestate.text = "inside max, inside CMDpanel" )
else ( lbl_mousestate.text = "inside max" )
) -- if contains maxbox mousepos
else ( lbl_mousestate.text = "outside max" )
Edit: This code works only in 3ds Max r7+ . 3ds Max r9+ users will probably want to replace the UI timer element with a .NET timer.
Edit2: Just playing with this, I think it'd drive me insane. That said.. you may wish to add checks to see if you're in a sub-edit mode and/or whether any particular modify panel-related dialogs opened (only in later max versions) and stop the command panel from being hidden if so.
06-03-2008, 02:24 PM
Thank you ZeBoxx2, worked it out, a lot fun. :D
06-04-2008, 01:00 PM
Is there a command that hides the menu bar?
06-04-2008, 01:36 PM
I don't think there is; unless loading an empty menu file would do that (eek)
But even the 'super expert mode' script in the help file only goes up to viewports+menubar.
06-05-2008, 10:59 AM
And a command to hide all the bottom bars?
06-05-2008, 03:20 PM
From the max help.. for a 'super expert mode'
trackbar.visible = false
statusPanel.visible = false
-- cui.expertModeOn() -- this only if you want to enter expert mode as well
06-06-2008, 07:50 AM
Thank you very much, ZeBoxx2!
OpenEXR is SplutterFish, great!
06-06-2008, 07:50 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.