Tutorial
|
|
|
|
OptionMenu
An OptionMenu is a widget that allows the user to
choose from a list of valid choices. The OptionMenu displays the
selected choice. When the OptionMenu activated it displays a popup menu
which allows the user to make a new choice.
Using an OptionMenu is simple; build a Gtk::Menu, then append menu
items to it with the Gtk::MenuShell append() method. Then create the
OptionMenu with a call to one of the following constructors:
OptionMenu();
explicit OptionMenu(Gtk::Menu&
menu, unsigned int index = 0); |
The first constructor creates an empty OptionMenu. The second
constructor lets you specify the popup menu to display and selects the
menu item specified by index, making it the newly selected
value for the option menu.
You can set the popup menu to display by calling:
void
set_menu(Gtk::Menu& menu);
|
and you can set the menu item to select by calling:
void
set_history(unsigned int index);
|
Don't forget to connect to the option menu changed signal
with
something like this:
option_menu->sig_changed().connect(slot(this, &MyClass::changed_handler));
|
You can retrieve the popup menu by calling:
Gtk::Menu* get_menu() const;
|
and you can get the index of the currently selected menu item by
calling:
If you need to change the menu you must remove the current menu first
with:
and that's all there is.