Description
The menubar object provides control over the menu bar. It allows your patch to put up its own menus, and add items to standard File and Edit menus. When a menu item is chosen, the item number is sent out the outlet corresponding to the menu containing the item.
Examples
Discussion
You configure the menubar by writing a script in a text editor window available by double-clicking on the object in a locked patcher.
When you close the script window and confirm saving the changes, the script file is interpreted. If there are no errors, the customized menu bar will be ready for use when menubar receives a nonzero number in its inlet.
Each message should be preceded by #X and end with a semicolon (; ).
Here is an example menubar script:
Note that we suggest capitalizing each letter in a menu item to maintain a consistent style with other items in the menu.
Arguments
display and behavior [int]
The argument sets the number of menus in the object's menu bar. If present, it must be at least 5 (one additional menu). The four default menus, which are always present, are File, Edit, Windows., and Help. On Macintosh, the Standard System Menu with the Apple icon and the Max application menu will appear to the left of the other menus.
Attributes
Common Box Attributes
annotation [symbol]
Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.
background [int] (default: 0)
Adds or removes the object from the patcher's background layer.
adds the object to the background layer, removes it. Objects in the background layer are shown behind all objects in the default foreground layer.color [4 floats]
Sets the color for the object box outline.
fontface [int]
Sets the type style used by the object. The options are:
plain
bold
italic
bold italic
Possible values:
0 = 'regular'
1 = 'bold'
2 = 'italic'
3 = 'bold italic'
fontname [symbol]
Sets the object's font.
fontsize [float]
Sets the object's font size (in points).
Possible values:
'8'
'9'
'10'
'11'
'12'
'13'
'14'
'16'
'18'
'20'
'24'
'30'
'36'
'48'
'64'
'72'
hidden [int] (default: 0)
Toggles whether an object is hidden when the patcher is locked.
hint [symbol]
Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.
ignoreclick [int] (default: 0)
Toggles whether an object ignores mouse clicks in a locked patcher.
patching_rect [4 floats] (default: 0. 0. 100. 0.)
Sets the position and size of the object in the patcher window.
position [2 floats]
Sets the object's x and y position in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its size unchanged.
presentation [int] (default: 0)
Sets whether an object belongs to the patcher's presentation.
presentation_rect [4 floats] (default: 0. 0. 0. 0.)
Sets the x and y position and width and height of the object in the patcher's presentation, leaving its patching position unchanged.
rect [4 floats]
Sets the x and y position and width and height of the object in both patching and presentation modes (if the object belongs to its patcher's presentation).
size [2 floats]
Sets the object's width and height in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its position unchanged.
textcolor [float]
Sets the color for the object's text in RGBA format.
textjustification [int]
Text Justification
Possible values:
0 = 'left'
1 = 'center'
2 = 'right'
varname [symbol]
Sets the patcher's scripting name, which can be used to address the object by name in pattr, scripting messages to thispatcher, and the js object.
Messages
int
Arguments
about
Arguments
• Text of the first menu item (i.e. About My Program…).
On the Macintosh the About item appears as the first item in the application menu (Max menu). On Windows, it appears as the first item in the Help menu. The message apple may be used optionally for compatibility with older Macintosh versions of Max.
append
Arguments
• Menu number
• Item number
• Text of item
• metacharacters (Optional.)
The message appends an item to an additional menu previously defined with a message.
You can alter the appearance of a menu item by including metacharacters in the item text (see the listing below for more information).
apple
Arguments
• Text of the first menu item (i.e. About My Program…).
On the Macintosh the About item appears as the first item in the application menu (Max menu). On Windows, it appears as the first item in the Help menu. This message may be used optionally for compatibility with older Macintosh versions of Max.
(mouse)
checkitem
Arguments
closeitem
edit
Arguments
• Item number to output
• Text of item to add to edit menu
The message inserts items into the standard Edit menu after the Clear item and before the Overdrive and Resume items (which are moved into the Edit menu when menubar is activated). A blank line separates the custom inserted items from the default items. Each item has a number associated with it which is sent out the third outlet of menubar when the item is chosen. The order in which your additional items appear in the Edit menu is determined by their order in the script, not by the (arbitrary) number associated with each item.
enableitem
Arguments
end
file
Arguments
• Item number to output
• Text of item to add to file menu
The message inserts items at the top of the standard File menu (before the Midi Setup... menu item). Each item has a number associated with it which is sent out the when the item is chosen. The order in which your additional items appear in the File menu is determined by their order in the script, not by the (arbitrary) number associated with each item.
item
Arguments
• Menu number
• Item number
• Text of item
• metacharacters (Optional.)
The message adds an item to an additional menu previously defined with a message. The order in which your items appear in the menu is determined by their order in the script, not by the (arbitrary) number associated with each item. The item number argument only specifies the number which is sent out the menubar object’s outlet when the user chooses this item. It’s a good idea to start your item numbers at 1 and list the items in the order you want them to appear in a menu.
You can alter the appearance of a menu item by including metacharacters in the item text. For more on metacharacters, consult the Apple QuickTime Developer documentation found at:
developer.apple.com
A few of the recognized meta-characters are:
/ : followed by a character, assigns that character as a Command-key equivalent
< : followed by B, I, O, S, or U, specifies a font style (such as O for outline)
! : followed by a character, marks the menu item with that character
(: disables the menu item
Thus, these special characters cannot appear as part of the actual item text. For example, the text will appear as , not as .
markitem
Arguments
menutitle
Arguments
• Menu number (must be at least 5 and must not exceed the number of outlets specified in the argument to the menubar object.
• Name of menu
The message adds a new menu before the Window menu. The first additional menu is number 5. The menu number determines both the order of the additional menu in the menu bar and the outlet it uses when the user chooses its items. A message must appear in the script before any messages that refer to its menu number.
newitem
Arguments
• Item number to output.
The message followed by a non-zero number directs Max to send the specified number out the menubar object’s File menu outlet when the user chooses the New command from the File menu, instead of opening a new patcher window. The message (or the absence of any message) causes the New command to behave normally.
open
Arguments
• Item number to output.
The message followed by a non-zero number directs Max to send the specified number out the menubar object’s File menu outlet when the user chooses the Open... command from the File menu, instead of displaying the Open Document dialog box. The message (or the absence of any message) causes the Open... command to behave normally.
saveas
Arguments
• Item number to output.
The message followed by a non-zero number directs Max to send the specified number out the menubar object’s File menu outlet when the user chooses Save or Save As... from the File menu, instead of performing the standard Save actions. The number sent out the outlet when Save is chosen will be 1 less than the number sent when Save As... is chosen. The message (or the absence of any message) causes the Save and Save As... commands to behave normally.
See Also
Name | Description |
---|---|
Sharing Max Patchers | Sharing Max Patchers |
umenu | Pop-up menu |