1. wxEuphoria: Drop Down Menu from Bitmap Button

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.

new topic     » topic index » view message » categorize

2. Re: wxEuphoria: Drop Down Menu from Bitmap Button

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!

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: wxEuphoria: Drop Down Menu from Bitmap Button

Spock said...
euphoric said...

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!

new topic     » goto parent     » topic index » view message » categorize

4. Re: wxEuphoria: Drop Down Menu from Bitmap Button

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: wxEuphoria: Drop Down Menu from Bitmap Button

Spock said...

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.

euphoric said...

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

new topic     » goto parent     » topic index » view message » categorize

6. Re: wxEuphoria: Drop Down Menu from Bitmap Button

ghaberek said...

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.

new topic     » goto parent     » topic index » view message » categorize

7. Re: wxEuphoria: Drop Down Menu from Bitmap Button

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... smile

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.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu