[Closed] For Bobo: Scripted Right-Click Menus
The current docs have a section describing the use of Scripted Right-Click Menus, but I’ve only been able to see them working in Max 3. The sample script from the docs loads fine in Max 4 and above, but does not show up in the Quad menus (no real surprise, of course). Its seems that the only complete example in the docs doesn’t work anymore.
-
Were the related commands registerRightClickMenu, unRegisterRightClickMenu and unRegisterAllRightClickMenus made obsolete in Max 4 and above?
-
Can right-click menus be created for UI items such as a listbox that would allow the event handlers for the RCmenu items to act on the specific listbox item/index that was right-clicked on?
It appears that I could trigger the display of an RCmenu by placing the popUpMenu command in an event handler for the listbox, such as the on doubleClicked event handler. However, I don’t see any way of actually triggering the RCmenu as the result of a right-click, except when dealing with a UI item that specifically supports a right-click event handler.
John,
I think you covered the reality of it pretty well
BUT you can pop up a right click menu in a ListView (both ActiveX and DotNet), so when I need RCmenu controls, I use a ListView instead of a listbox. In fact, I have some internal scripts completely controlled via RCMenu and a ListView containing all the data to generate stuff…
Thanks for the confirmation, Bobo.
Regarding the RCmenu and related features, the current docs are almost completely unchanged since Max 3 and definitely don’t help the novice understand how to code them. Below are some points that I think need to be addressed in the current docs:
-
The Rollout User-Interface Control Types->PopupMenu page needs to have a link to the Scripted Right-Click Menus page. The popUpMenu command is unlike any other UI item, yet there is currently no direct link to more info on RCmenu clauses and how to use them.
-
The Scripted Right-Click Menus page needs some history added describing how the Max 4 introduction of the quad menus changed the main usage of the RCmenu, especially how the original method of triggering the display of an RCmenu no longer works at all. The registerRightClickMenu, unRegisterRightClickMenu and unRegisterAllRightClickMenus commands should be either removed or clearly labeled as obsolete.
-
The RCmenu example code included on the Scripted Right-Click Menus page is obsolete in Max 4 and above, and it should be replaced. I’ve included a possible replacement below that shows how to integrate it with the other UI items and their event handlers. I’ve never used an RCmenu before today, so feel free to correct/optimize anything that doesn’t look right.
(
try (destroyDialog MyRollout) catch ()
resetMaxFile #noPrompt
global MyRollout
global MyObjects = #(cone pos:[-50,50,0], sphere pos:[50,50,0], pyramid pos:[50,-50,0])
rcmenu MyRCmenu
(
menuItem mi_box "Display as Box" checked:false
menuItem mi_frz "Freeze" checked:false
on MyRCmenu open do
(
local CurNode = MyObjects[(MyRollout.MyLbx.selection)]
local IsValNode = (IsValidNode CurNode)
-- Enable items only if node is still valid
mi_box.enabled = mi_frz.enabled = IsValNode
-- Set check state of items
if IsValNode do
(
mi_box.checked = CurNode.boxmode
mi_frz.checked = CurNode.isFrozen
)
)
-- Set up event handlers for items
on mi_box picked do
(
local CurNode = MyObjects[(MyRollout.MyLbx.selection)]
CurNode.boxmode = (not CurNode.boxmode)
)
on mi_frz picked do
(
local CurNode = MyObjects[(MyRollout.MyLbx.selection)]
CurNode.isFrozen = (not CurNode.isFrozen)
)
)
rollout MyRollout "MyRollout: (double-click items for RCmenu)"
(
listbox MyLbx items:(for i=1 to MyObjects.count collect MyObjects[i].name)
on MyLbx doubleClicked val do (popUpMenu MyRCmenu)
)
createDialog MyRollout width:300
)
Bobo, did you see this last reply of mine?
(I want to be sure, since the docs are currently quite confusing on this subject.)
Yep, I pasted it into my todo list.
At the moment, I am technically not able to work on the documentation.
If Autodesk hires me for another year, I will make sure these things get addressed.
Thanks!
Bobo