Fl_Widget | +----Fl_Menu_Item----Fl_Menu_
#include <FL/Fl_Menu_Item.H>
struct Fl_Menu_Item { const char* text; // label() ulong shortcut_; Fl_Callback* callback_; void* user_data_; int flags; uchar labeltype_; uchar labelfont_; uchar labelsize_; uchar labelcolor_; }; enum { // values for flags: FL_MENU_INACTIVE = 1, FL_MENU_TOGGLE = 2, FL_MENU_VALUE = 4, FL_MENU_RADIO = 8, FL_MENU_INVISIBLE = 0x10, FL_SUBMENU_POINTER = 0x20, FL_SUBMENU = 0x40, FL_MENU_DIVIDER = 0x80, FL_MENU_HORIZONTAL = 0x100 };Typically menu items are statically defined; for example:
Fl_Menu_Item popup[] = { {", FL_ALT+'a', the_cb, (void*)1}, {", FL_ALT+'b', the_cb, (void*)2}, {"gamma", FL_ALT+'c', the_cb, (void*)3, FL_MENU_DIVIDER}, {", 0, strange_cb}, {", 0, charm_cb}, {", 0, truth_cb}, {"b, 0, beauty_cb}, {"sub, 0, 0, 0, FL_SUBMENU}, {"one"}, {"two"}, {"three"}, {0}, {"inactive", FL_ALT+'i', 0, 0, FL_MENU_INACTIVE|FL_MENU_DIVIDER}, {"invisible",FL_ALT+'i', 0, 0, FL_MENU_INVISIBLE}, {"check", FL_ALT+'i', 0, 0, FL_MENU_TOGGLE|FL_MENU_VALUE}, {"box", FL_ALT+'i', 0, 0, FL_MENU_TOGGLE}, {0}}; |
You should use the method functions to access structure members and not access them directly to avoid compatibility problems with future releases of FLTK.
The key can be any value returned by Fl::event_key(), but will usually be an ASCII letter. Use a lower-case letter unless you require the shift key to be held down.
The shift flags can be any set of values accepted by Fl::event_state(). If the bit is on that shift key must be pushed. Meta, Alt, Ctrl, and Shift must be off if they are not in the shift flags (zero for the other bits indicates a "don't care" setting).
X,Y is the position of the mouse cursor, relative to the window that got the most recent event (usually you can pass Fl::event_x() and Fl::event_y() unchanged here).
title is a character string title for the menu. If non-zero a small box appears above the menu with the title in it.
The menu is positioned so the cursor is centered over the item picked. This will work even if picked is in a submenu. If picked is zero or not in the menu item table the menu is positioned with the cursor in the top-left corner.
button is a pointer to an Fl_Menu_ from which the color and boxtypes for the menu are pulled. If NULL then defaults are used.
The title and menubar arguments are used internally by the Fl_Menu_ widget.