Livecode Wiki

Stack Menus Button menus can be used for most kinds of standard menus. However, if you want to create a menu with a feature that is not supported by button menus--for example, if you want a popup menu that provides pictures, rather than text, as the choices--you can create a menu from a stack.

Creating a stack menu: To create a stack menu, you create a stack with a control for each menu item. Since the stack menu is a stack and each menu item is an object, the menu items receive mouse messages such as mouseEnter, mouseLeave, and mouseUp.

When the user chooses an item from the stack menu, a mouseUp message is sent to that control. To respond to a menu item choice, instead of handling the menuPick message, you can place a mouseUp handler in the script of the object.

To create a stack menu that looks like a standard menu, create a button in the stack for each menu item. The button's autoArm and armBorder properties should be set to true. Or you can choose "Menu Item" item in the "New Control" submenu of the Object menu to create a button with its properties set to the appropriate values.

Be sure to set the rectangle of the stack to the appropriate size for the menu. Remember, when you open the menu, the stack will be displayed exactly as it looks in an editable window.

Finally, either set the menuName property of a button to a reference to the stack, or place a mouseDown handler containing a pulldown, popup, or option command in the script of an object. When you click the button or object, the stack menu appears.

Displaying a stack menu: Stack menus can be associated with a button, just like button menus. But when you click the button, instead of displaying a menu with the button's contents, Revolution displays a stack with the behavior of a menu.

You can also display a stack menu without associating it with a button, by using the pulldown, popup, or option command. Normally, you use these commands in a mouseDown handler, so that the menu appears under the mouse pointer:

  on mouseDown -- in card script     popup stack "My Menu Panel"   end mouseDown