FLTK 1.3.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions
Fl_Menu_Button Class Reference

This is a button that when pushed pops up a menu (or hierarchy of menus) defined by an array of Fl_Menu_Item objects. More...

`#include <Fl_Menu_Button.H>`

Inheritance diagram for Fl_Menu_Button:

List of all members.

## Public Types
enum | popup_buttons { POPUP1 = 1, POPUP2, POPUP12, POPUP3, POPUP13, POPUP23, POPUP123 }
| indicate what mouse buttons pop up the menu. More...
## Public Member Functions
| Fl_Menu_Button (int, int, int, int, const char *=0)
| Creates a new Fl_Menu_Button widget using the given position, size, and label string.
int | handle (int)
| Handles the specified event.
const Fl_Menu_Item * | popup ()
| Act exactly as though the user clicked the button or typed the shortcut key.
## Protected Member Functions
void | draw ()
| Draws the widget.

## Detailed Description

This is a button that when pushed pops up a menu (or hierarchy of menus) defined by an array of Fl_Menu_Item objects.

Normally any mouse button will pop up a menu and it is lined up below the button as shown in the picture. However an Fl_Menu_Button may also control a pop-up menu. This is done by setting the type(). If type() is zero a normal menu button is produced. If it is nonzero then this is a pop-up menu. The bits in type() indicate what mouse buttons pop up the menu (see Fl_Menu_Button::popup_buttons).

The menu will also pop up in response to shortcuts indicated by putting a '&' character in the label().

Typing the shortcut() of any of the menu items will cause callbacks exactly the same as when you pick the item with the mouse. The '&' character in menu item names are only looked at when the menu is popped up, however.

When the user picks an item off the menu, the item's callback is done with the menu_button as the Fl_Widget* argument. If the item does not have a callback the menu_button's callback is done instead.

## Member Enumeration Documentation

enum Fl_Menu_Button::popup_buttons

indicate what mouse buttons pop up the menu.

Values for type() used to indicate what mouse buttons pop up the menu. Fl_Menu_Button::POPUP3 is usually what you want.

Enumerator:

  POPUP1 | pops up with the mouse 1st button.
  POPUP2 | pops up with the mouse 2nd button.
  POPUP12 | pops up with the mouse 1st or 2nd buttons.
  POPUP3 | pops up with the mouse 3rd button.
  POPUP13 | pops up with the mouse 1st or 3rd buttons.
  POPUP23 | pops up with the mouse 2nd or 3rd buttons.
  POPUP123 | pops up with any mouse button.

## Constructor & Destructor Documentation

Fl_Menu_Button::Fl_Menu_Button | ( | int | X,
|  | int | Y,
|  | int | W,
|  | int | H,
|  | const char * | l = `0`
| ) |  |

Creates a new Fl_Menu_Button widget using the given position, size, and label string.

The default boxtype is FL_UP_BOX.

The constructor sets menu() to NULL. See Fl_Menu_ for the methods to set or change the menu.

## Member Function Documentation

void Fl_Menu_Button::draw | ( |  | ) | `[protected, virtual]`

Draws the widget.

Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must be redrawn as soon as possible, call redraw() instead.

Override this function to draw your own widgets.

If you ever need to call another widget's draw method from within your own draw() method, e.g. for an embedded scrollbar, you can do it (because draw() is virtual) like this:

            Fl_Widget *s = &scroll;         // scroll is an embedded Fl_Scrollbar
            s->draw();                      // calls Fl_Scrollbar::draw()

Implements Fl_Widget.

int Fl_Menu_Button::handle | ( | int | event | ) | `[virtual]`

Handles the specified event.

You normally don't call this method directly, but instead let FLTK do it when the user interacts with the widget.

When implemented in a widget, this function must return 0 if the widget does not use the event or 1 otherwise.

Most of the time, you want to call the inherited handle() method in your overridden method so that you don't short-circuit events that you don't handle. In this last case you should return the callee retval.

Parameters:

  [in] | event | the kind of event received

Return values:

  0 | if the event was not used or understood
  1 | if the event was used and can be deleted

See also:
  Fl_Event

Reimplemented from Fl_Widget.

const Fl_Menu_Item * Fl_Menu_Button::popup | ( |  | ) |

Act exactly as though the user clicked the button or typed the shortcut key.

The menu appears, it waits for the user to pick an item, and if they pick one it sets value() and does the callback or sets changed() as described above. The menu item is returned or NULL if the user dismisses the menu.

The documentation for this class was generated from the following files:

- Fl_Menu_Button.H
- Fl_Menu_Button.cxx