Re: wxEuphoria: Drop Down Menu from Bitmap Button
- Posted by ghaberek (admin) Aug 10, 2015
- 1517 views
euphoric said...
I'd like to have a button that when clicked would display a dropdown menu, but there doesn't seem to be a control specific for that. I've got a bitmap button on-screen. What can I do to "drop down" a menu from that when clicked? Any hints, tips, tricks, or links welcome!
Just catch the button's click event and then call show_popup_menu with the relative coordinates to place the menu below the button.
include wxeu/wxeud.e constant NULL = 0, wxID_ANY = -1 constant bitmap = create( wxBitmap, {BM_FROM_FILE, "image.png", wxBITMAP_TYPE_PNG} ), $ constant Main = create( wxFrame, {NULL, wxID_ANY, "Bitmap Button Menu", -1, -1, 640, 480} ), Panel = create( wxPanel, {Main} ), Button = create( wxBitmapButton, {Panel, wxID_ANY, bitmap, 10, 10} ), Popup = create( wxMenu, {NULL} ), PopupItem1 = create( wxMenuItem, {Popup, wxID_ANY, "Click me"} ), $ procedure Button_OnClick( atom this, atom event_type, atom id, atom event ) sequence rect = get_rect( Button ) -- {x, y, width, height} show_popup_menu( Panel, Popup, rect[1], rect[2]+rect[4] ) end procedure set_event_handler( Button, wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, routine_id("Button_OnClick") ) wxMain( Main )
-Greg