NAME

Fl::MenuButton - Button that Pops Up a Menu

Description

This is a button that when pushed pops up a menu (or hierarchy of menus) defined by an array of Fl::MenuItem 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::MenuButton 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::MenuButton->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.

Methods

Fl::MenuButton inherits from Fl::Menu and Fl::Widget. On top of that, it exposes the following methods...

new(...)

my $ic_a = Fl::MenuButton->new(0, 0, 250, 500, 'Important Stuff');
my $ic_b = Fl::MenuButton->new(0, 0, 250, 500);

The constructor creates a new widget using the given position, size, and label.

The default boxtype is FL_UP_BOX.

The destructor removes the widget.

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.

LICENSE

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Sanko Robinson <sanko@cpan.org>