Scripted Right-Click Menus

MAXScript provides a set of classes and functions and some special syntax to allow you to construct custom right-click menus.

Feature History

In versions prior to 3ds Max 4 when the QuadMenu system was still not available, scripted right-click menus could be incorporated into the existing 3ds Max user interface. The typical use of right-click menus was to provide quick access to a selection of tools written in MAXScript. These tools would typically have no user interface, however one could create dialogs or rollout floater windows in a right-click menu to display a user interface

For an example and list of deprecated methods, see the topic Deprecated RCmenu Methods

Current Usage

With the introduction of the QuadMenu system in 3ds Max 4, registering custom scripted right-click menus became impossible, but the menus themselves can still be used in scripted tools:

Creation

A scripted right-click menu is created using the RCMenu definition construct in MAXScript, and then you register the right-click menu with 3ds Max. The top-level definition syntax is as follows:

rcmenu <var_name> ( <rcmenu_body> )

where:

<var_name> is the name of an automatically created global variable to hold the rcmenu value that represents the right-click menu.

<rcmenu_body> is enclosed in the required parentheses and is a sequence of clauses that define the menu items that will appear in the utility, along with functions and event handlers that process user interactions. These clauses are defined in detail in RCMenu Clauses.

Methods

popUpMenu <RCMenu> [pos:<Point2>] [rollout:<Rollout>] [align:<key>]

This method will popup a menu anywhere on the screen. The controls are as follows:

<RCMenu>: Any RCMenu defined. It does not have to be registered.

\[pos:<Point2>\]: The point where the menu pops up, either relative to the Rollout or the screen. (Default: popup from current mouse position.)

\[rollout:<Rollout>\]: This will make the menu popup from a rollouts local coordinate system. Specifying undefined will cause the menu to popup relative to the upper left corner of the screen. (Default: undefined)

\[align:<key>\]: Can be one of the following (Default: #align_topleft ):

 #align_topleft #align_topcenter #align_topright #align_bottomleft #align_bottomcenter #align_bottomright #align_vcenterleft #align_vcentercenter #align_vcenterright

If a runtime error occurs while executing a scripted right-click menu, an error message is displayed in Listener. The right-click menu will not be disabled.