1. wxEuphoria: Drop Down Menu from Bitmap Button
- Posted by euphoric (admin) Aug 03, 2015
- 1537 views
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!
Thank you.
2. Re: wxEuphoria: Drop Down Menu from Bitmap Button
- Posted by Spock Aug 03, 2015
- 1535 views
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!
Thank you.
Could you not just use a popup menu as a (very) quick alternative? Maybe not so slick but highly functional. User clicks button and your code calls something like:
popup( MYLITTLEMENU, x, y )
Spock
3. Re: wxEuphoria: Drop Down Menu from Bitmap Button
- Posted by euphoric (admin) Aug 03, 2015
- 1523 views
I'd like to have a button that when clicked would display a dropdown menu...
Could you not just use a popup menu as a (very) quick alternative? Maybe not so slick but highly functional. User clicks button and your code calls something like:
popup( MYLITTLEMENU, x, y )
You helped me refine a search, and I've found a wxPopupWindow control. That might be the key. Thanks!
4. Re: wxEuphoria: Drop Down Menu from Bitmap Button
- Posted by ghaberek (admin) Aug 10, 2015
- 1500 views
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
5. Re: wxEuphoria: Drop Down Menu from Bitmap Button
- Posted by ghaberek (admin) Aug 10, 2015
- 1457 views
Could you not just use a popup menu as a (very) quick alternative? Maybe not so slick but highly functional. User clicks button and your code calls something like:
popup( MYLITTLEMENU, x, y )
popup is from Win32Lib, but what I've demonstrated with show_popup_menu in wxEuphoria is the same.
You helped me refine a search, and I've found a wxPopupWindow control. That might be the key. Thanks!
wxPopupWindow is for building your own transient dropdown-like controls. Basically, it's a frameless window that is dismissed automatically when it loses focus.
-Greg
6. Re: wxEuphoria: Drop Down Menu from Bitmap Button
- Posted by euphoric (admin) Aug 10, 2015
- 1483 views
Just catch the button's click event and then call show_popup_menu with the relative coordinates to place the menu below the button.
Thanks, Greg! That works perfectly.
7. Re: wxEuphoria: Drop Down Menu from Bitmap Button
- Posted by euphoric (admin) Aug 10, 2015
- 1497 views
Greg, if I wanted to add menu items dynamically (I'm building a path history list that gets read from a text file), how would I go about doing that? I'll be adding to the list during runtime. Would I keep creating wxMenuItems as needed? How do I prevent duplicates? etc...
Thank you!
ADDED: When the user clicks a wxMenuItem, I want to change the current directory, update another control (textbox), etc. How do I capture the wxMenuItem clicks, especially for ones added during runtime?
ADDED: Found the wxMenuItem demo file. Will investigate...
ADDED: I got it working! I will post the deets later, for knowledgebase purposes.