|
WINDEX
|
A drop down list of options that user can click to start an action. More...
#include <wex.h>
Public Member Functions | |
| menu (gui &parent) | |
| void | append (const std::string &title, const std::function< void(const std::string &)> &f=[](const std::string &title) {}) |
| Append menu item. More... | |
| void | append (const std::string &title, menu &submenu) |
| Append submenu. More... | |
| void | popup (int x, int y) |
| Popup menu and run user selection. More... | |
| HMENU | handle () |
| bool | check (int index, bool f=true) |
| Set or unset check mark beside menu item. More... | |
| int | size () |
| Number of items in menu. | |
A drop down list of options that user can click to start an action.
// construct top level window
gui& form = wex::windex::topWindow();
form.move({ 50,50,400,400});
form.text("Menu demo");
int clicked = -1;
menu m( form );
m.append("test",[&](const std::string &title)
{
clicked = 1;
});
m.append("second",[&](const std::string &title)
{
clicked = 2;
});
m.append("third",[&](const std::string &title)
{
clicked = 3;
});
m.popup( form, 200,200 );
msgbox( form,std::string("item ") + std::to_string(clicked) + " clicked");
form.show();
|
inline |
Append menu item.
| [in] | title | |
| [in] | f | function to be run when menu item clicked |
The function signature is void f( const std::string& title ).
The title can be used by the function if it needs to know the menue item title that caused execution i.e when several items invoke the same function
|
inline |
Append submenu.
| [in] | title | |
| [in] | submenu |
|
inline |
Set or unset check mark beside menu item.
| [in] | index | 0-based index of menu item |
| [in] | f | true if menu item is to be checked, default true |
|
inline |
Popup menu and run user selection.
| [in] | x | location |
| [in] | y | location |