#include <umenu.hpp>
Inheritance diagram for ubit::UPopmenu:
Public Member Functions | |
UPopmenu (const UArgs &a=UArgs::none) | |
create a new Contextual menu. | |
Static Public Member Functions | |
static UStyle * | createStyle () |
< important: all subclasses MUST contain this declaration. static function that returns the UStyle of this class (see details!). | |
Friends | |
UPopmenu & | upopmenu (const UArgs &a=UArgs::none) |
shortcut that returns *new UPopmenu(a). |
In contrast with superclass UMenu, UPopmenu instances are not automatically opened when the mouse is pressed in one of their parents. Instead, one of their show() methods must be called explicitely as in the example below:
UPopmenu& menu = // a popup menu with 3 buttons upopmenu(ubutton(...) + ubutton(...) + ubutton(...));
UBox& box = ubox(...); // a widget that will open the menu UBox* btn = new UButton(...) // another widget that will open the menu box.add(menu); // a menu MUST have at least one realized parent
// the menu is opened when the mouse is pressed on the button btn->add(UOn::mpress / ucall(&menu, &UMenu::open));
// the menu is opened when the mouse is pressed on the box by using // Button3 or Button1 with the Control modifier pressed box.add(UOn::mpress / ucall(&menu, openMenuCB));
void openMenuCB(UMouseEvent& e, UPopmenu* m) { if (e.getButton() == e.RightButton || (e.getButton() == e.LeftButton && e.isControlDown())) m->open(e); }Note: as other Ubit objects, popmenus MUST HAVE at least one parent.
UStyle * ubit::UPopmenu::createStyle | ( | ) | [static] |
< important: all subclasses MUST contain this declaration. static function that returns the UStyle of this class (see details!).
this macro defines the UClass that corresponds to this class and:
Reimplemented from ubit::UMenu.
Reimplemented in ubit::UCtlmenu, and ubit::UPiemenu.