Class Menu_

(back to index)

Abstract base class for FLTK menus

Inherits from Widget

Subclasses: Choice  Menu_Bar  Menu_Button  

Property index

down_boxtexttextfontvalue
sizetextcolortextsize

Function index

addglobalmodereplaceshortcut
clearitem_textremoveset_mode

Key properties

typenamesummary
integer valueOffset of last item chosen
readonly string textText of last item chosen

Key functions

typenamesummary
integer add(Menu_Entry m_e)Add an entry
void clear()Remove all entries

Description

All widgets that have a menu in FLTK are subclassed off of this class. Currently FLTK provides you with Menu_Button, Menu_Bar, and Choice.

You can either directly manipulate the contents of the menu by adding strings and writing your callbacks in terms of item index numbers, or you can use the Menu_Entry wrapper.

Menu_Entry isn't an FLTK class; it's an invention of the Lua FLTK wrapper. It looks somewhat like an Fl_Menu_Item.

Detailed reference

global(): void

Make the shortcuts for this menu work no matter what window has the focus when you type it. This is done by using the FLTK function Fl::add_handler(). This Menu_ widget does not have to be visible (ie the window it is in can be hidden, or it does not have to be put in a window at all).

Currently there can be only one global()menu. Setting a new one will replace the old one. There is no way to remove the global() setting (so don't destroy the widget!)

size: readonly integer

The number of entries currently in the menu, plus one. (The extra is for a hidden terminator entry.) If no items have ever been added, this is zero.

clear(): void

Removes all entries from the menu.

add(Menu_Entry m_e): integer

Adds a Menu_Entry to the menu at the end of the items list. Returns the 0-based offset it was placed at. See Menu_Entry for more information.

As a convenience, if m_e is a string, a Menu_Entry will be wrapped around it for you.

replace(integer offset, string label): void

Changes the text of item n.

Don't use this function if you're using Menu_Entrys; update the label and call redraw() on the Menu_Entry instead.

remove(integer offset): void

Deletes item n from the menu.

Note that all offsets after the deleted item will change.

shortcut(integer offset, integer shortcut): void

Changes the shortcut of the entry.

Don't use this function if you're using Menu_Entrys; update the shortcut and call redraw() on the Menu_Entry instead.

set_mode(integer offset, integer flags): void

Changes the flags of the entry.

Don't use this function if you're using Menu_Entrys; update the flag properties and call redraw() on the Menu_Entry instead.

mode(integer offset): int

Return the current flags of the entry.

value: integer

The value is the index of the last item chosen by the user. It is zero initially.

text: readonly string

Returns the label of the last item chosen.

item_text(integer offset): int

Returns the label of the item.

textfont: Font

The default text font for menu items.

textsize: integer

The default text font size for menu items.

textcolor: Color

The default color for the text of menu items.

down_box: Boxtype

This box type is used to surround the currently-selected items in the menus. If this is Boxtype.none then it acts like Boxtype.thin_up and selection_color acts like Color.white, for back compatability.


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