Switch Bug

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

I'd like to implement a simple switch block to handle multiple event IDs from one handler. However, I'm having a problem and I hope I'm not just missing something. In the demo below, regardless of which menu item I select, it always jumps to the "Exit" block, except when I actually choose "Exit", then it jumps to the else block instead. Is this the same bug listed here? This demo was made with Euphoria 4.0.2 and wxEuphoria 0.15.0.

-Greg

include "wxeu/wxeud.e" 
without warning 
 
include "std/text.e" 
 
object void 
 
constant  
    wxID_CUSTOM1        = new_id(), 
     
    frmMain             = create( wxFrame, {0, -1, "Menu Demo", -1, -1, 480, 360} ), 
    mbrMain             = create( wxMenuBar, {frmMain} ), 
    mnuFile             = create( wxMenu, {mbrMain, "&File"} ), 
    mnuFile_New         = create( wxMenuItem, {mnuFile, wxID_NEW, "&New"} ), 
    mnuFile_Open        = create( wxMenuItem, {mnuFile, wxID_OPEN, "&Open..."} ), 
    mnuFile_Save        = create( wxMenuItem, {mnuFile, wxID_SAVE, "&Save"} ), 
    mnuFile_SaveAs      = create( wxMenuItem, {mnuFile, wxID_SAVEAS, "Save &As..."} ), 
    mnuFile_PageSetup   = create( wxMenuItem, {mnuFile, wxID_PRINT_SETUP, "Page Set&up..."} ), 
    mnuFile_Print       = create( wxMenuItem, {mnuFile, wxID_PRINT, "&Print..."} ), 
    mnuFile_Custom1     = create( wxMenuItem, {mnuFile, wxID_CUSTOM1, "Custom 1"} ), 
    mnuFile_Exit        = create( wxMenuItem, {mnuFile, wxID_EXIT, "E&xit"} ), 
    lstCtrl             = create( wxListCtrl, {frmMain} ), 
    $ 
 
insert_separator( mnuFile, 4 ) -- after "Save As" 
insert_separator( mnuFile, 7 ) -- after "Print" 
insert_separator( mnuFile, 9 ) -- after "Custom 1" 
 
void = insert_list_column( lstCtrl, 0, "ID", 0, 160 ) 
void = insert_list_column( lstCtrl, 1, "Value", 0, 240 ) 
void = insert_listctrl_item( lstCtrl, 0, {"wxID_NEW",sprint(wxID_NEW)}, 0 ) 
void = insert_listctrl_item( lstCtrl, 1, {"wxID_OPEN",sprint(wxID_OPEN)}, 0 ) 
void = insert_listctrl_item( lstCtrl, 2, {"wxID_SAVE",sprint(wxID_SAVE)}, 0 ) 
void = insert_listctrl_item( lstCtrl, 3, {"wxID_SAVEAS",sprint(wxID_SAVEAS)}, 0 ) 
void = insert_listctrl_item( lstCtrl, 4, {"wxID_PRINT_SETUP",sprint(wxID_PRINT_SETUP)}, 0 ) 
void = insert_listctrl_item( lstCtrl, 5, {"wxID_PRINT",sprint(wxID_PRINT)}, 0 ) 
void = insert_listctrl_item( lstCtrl, 6, {"wxID_CUSTOM1",sprint(wxID_CUSTOM1)}, 0 ) 
void = insert_listctrl_item( lstCtrl, 7, {"wxID_EXIT",sprint(wxID_EXIT)}, 0 ) 
 
procedure menu_handler( atom this, atom event_type, atom id, atom event ) 
     
    sequence message 
     
    switch id do 
         
        case wxID_NEW then 
            message = "New" 
             
        case wxID_OPEN then 
            message = "Open" 
             
        case wxID_SAVE then 
            message = "Save" 
             
        case wxID_SAVEAS then 
            message = "Save As" 
             
        case wxID_PRINT_SETUP then 
            message = "Page Setup" 
             
        case wxID_PRINT then 
            message = "Print" 
             
        case wxID_CUSTOM1 then 
            message = "Custom 1" 
             
        case wxID_EXIT then 
            message = "Exit" 
             
        case else 
            message = "Unknown command" 
             
    end switch 
     
    void = message_box( sprintf("%s (ID %d)", {message, id}), "Menu Handler", wxICON_INFORMATION ) 
     
end procedure 
set_event_handler( frmMain, -1, wxEVT_COMMAND_MENU_SELECTED, routine_id("menu_handler") ) 
 
wxMain( frmMain ) 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu