Class Menu_Entry

(back to index)

Wrapper class for menu items

Property index


Function index


Key properties

string labelPath and label
function callbackCalled when chosen

Key functions

void redraw()Update the menu item state


Menu_Entry wraps the creation and maintenance of menu items in Menu_ subclasses. It compensates for the lack of a Lua binding to Fl_Menu_Item

To create them, call their constructor Menu_Entry{"your label"}. Once added to a Menu_, they're associated with that menu; don't add them again elsewhere.

Changes to properties won't take effect until you call redraw() on the entry.

Detailed reference

label: string

The label to display for this entry. It also specifies the place in the menu hierarchy. For example, a label of "Edit/Paste" will place an entry displayed as Paste in the Edit menu.

Note that you should not create an entry labeled "Edit" in this case; it will be properly created as a submenu for you.

'&' shortcuts may be included. See Button's label property for more information.

callback: function

callback will be called when the item is chosen. If callback is nil, the Menu_'s callback will be invoked instead.

inactive: boolean

Selects whether the item is disabled. Disabled items are grayed out and cannot be picked.

toggle: boolean

Controls whether the item is a check button. Check buttons have a box drawn adjacent to them; chosing one toggles its value. See get_value() and set_value()

radio: boolean

Controls whether the item is a radio button. Radio button have a box drawn adjacent to them. When a radio button is selected all "adjacent" radio buttons are turned off. A set of radio items is delimited by a non-radio item, or by an item with divider turned on.. See get_value() and set_value()

Note that you must manually deselect other radio buttons in the group before selecting one programmatically.

invisible: boolean

Controls whether the item is shown.

divider: boolean

If divider is true, a menu divider is drawn after this item.

value: boolean

For radio and check buttons, choose whether the entry is selected. This is really only useful in constructors as it lags behind the menu state. Use get_value() and set_value() instead.

shortcut: integer

Controls the keyboard trigger for the menu item. shortcut is an integer consisting of an ASCII character or extended keycode, with modifiers. strbyte('a')+Modifier.ctrl is Ctrl-A; Key.insert+Modifier.shift is Shift-Insert. See Key and Modifier for more information.

get_value(): boolean

Returns true if the item (presumably a check or radio button) is selected.

set_value(boolean b): void

Sets the value flag of the item (presumably a check or radio button) to b. redraw() is called for you.

Note that this does not turn off other members of a radio group; turn them off by hand before turning another on programatically

redraw(): void

A Menu_Entry is only a wrapper for an item in a menu. After modifying the state, call redraw() to force changes into the real menu.

doctool generated at Sun Aug 12 22:23:18 2001