Re: wxEuphoria - On hover

new topic     » goto parent     » topic index » view thread      » older message » newer message
Steady said...

I think wxmenu would work. I do not know how to make it vertical instead of horizontal.

To create a submenu, first create a wxMenu object with no parent, then create a new wxMenuItem with the menu as the subMenu parameter.

Here is an example showing:

  • how to create a popup menu
  • how to create sub-menus
  • how to show a popup menu when a button is clicked

Edit: here's a better demo that builds the menus with loops and tracks their values using a map.

include wxeu/wxeud.e 
include std/map.e 
 
constant NULL = 0 
constant wxID_ANY = -1 
 
atom frame    = create( wxFrame, {NULL, wxID_ANY, "Popup Menu Demo", -1, -1, 400, 300} ) 
atom panel    = create( wxPanel, {frame, wxID_ANY} ) 
atom button   = create( wxButton, {panel, wxID_ANY, "Select", 30, 30, 90, 30} ) 
atom popup    = create( wxMenu, {NULL} ) 
 
map m_text = map:new() 
 
atom menu, item, subitem, id 
sequence text 
 
for i = 1 to 6 do 
     
    text = sprintf( "Menu %d", {i} ) 
    menu = create( wxMenu, {NULL} ) 
    item = create( wxMenuItem, {popup, wxID_ANY, text, "", wxITEM_NORMAL, menu} ) 
     
    for j = 1 to 8 do 
         
        id = new_id() 
        text = sprintf( "Item %d-%d", {i,j} ) 
         
        subitem = create( wxMenuItem, {menu, id, text} ) 
        map:put( m_text, id, text ) 
         
    end for 
     
end for 
 
procedure button_clicked( atom this, atom event_type, atom id, atom event ) 
     
    sequence rect = get_rect( button ) 
    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_clicked") ) 
 
procedure menuitem_clicked( atom this, atom event_type, atom id, atom event ) 
     
    sequence text = map:get( m_text, id, "unknown" ) 
    message_box( sprintf("You clicked on '%s' (id = %d)", {text,id}), "Popup Menu Demo", wxICON_INFORMATION ) 
     
end procedure 
set_event_handler( popup, wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, routine_id("menuitem_clicked") ) 
 
wxMain( frame ) 
Steady said...

The wxTreectl might also work and work in a vertical way. Where can I find the samples of wxTreectl

There is a wxTreeCtrl and wxListCtrl demo included with wxEuphoria, called tree_list_demo.exw.

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu