1. wxEuphoria wxEVT_CLOSE_WINDOW
- Posted by cklester <cklester at yahoo.com> Dec 04, 2005
- 564 views
I'm trying to trap the close window event when the user clicks the upper-right 'X' on the title bar. I can't seem to do it! Here's my procedure: procedure byebye( atom this, atom event_type, atom id, atom event ) save_plan() exit_main() end procedure set_event_handler( frame_Main, wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, routine_id("byebye")) set_event_handler( frame_Main, -1, wxEVT_CLOSE_WINDOW, routine_id("byebye")) The menu one works fine, but not the wxEVT_CLOSE_WINDOW one. I've researched this in the forum history and in the docs/demos, but I can't find an example. -=ck "Programming in a state of Euphoria." http://www.cklester.com/euphoria/
2. Re: wxEuphoria wxEVT_CLOSE_WINDOW
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Dec 05, 2005
- 521 views
cklester wrote: > > I'm trying to trap the close window event when the user clicks the upper-right > 'X' on the title bar. I can't seem to do it! Here's my procedure: > > procedure byebye( atom this, atom event_type, atom id, atom event ) > save_plan() > exit_main() > end procedure > set_event_handler( frame_Main, wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, > routine_id("byebye")) > set_event_handler( frame_Main, -1, wxEVT_CLOSE_WINDOW, routine_id("byebye")) > > The menu one works fine, but not the wxEVT_CLOSE_WINDOW one. I've researched > this in the forum history and in the docs/demos, but I can't find an example. wxEVT_CLOSE_WINDOW should work. The following 'works' for me:
include wxEuphoria.e constant frame_Main = create( wxFrame, {0, -1, "Main"}) procedure byebye( atom this, atom event_type, atom id, atom event ) ? 1/0 end procedure set_event_handler( frame_Main, -1, wxEVT_CLOSE_WINDOW, routine_id("byebye")) wxMain( frame_Main )
3. Re: wxEuphoria wxEVT_CLOSE_WINDOW
- Posted by cklester <cklester at yahoo.com> Dec 05, 2005
- 534 views
Matt Lewis wrote: > wxEVT_CLOSE_WINDOW should work. The following 'works' for me: > > }}} <eucode> > include wxEuphoria.e > > constant > frame_Main = create( wxFrame, {0, -1, "Main"}) > > procedure byebye( atom this, atom event_type, atom id, atom event ) > ? 1/0 > end procedure > set_event_handler( frame_Main, -1, wxEVT_CLOSE_WINDOW, routine_id("byebye")) > > wxMain( frame_Main ) > </eucode> {{{ I expect a console to pop up here when I click the 'X' in the title bar to close the app, but all that happens is the program closes. I don't get the expected error message about dividing by zero. -=ck "Programming in a state of Euphoria." http://www.cklester.com/euphoria/
4. Re: wxEuphoria wxEVT_CLOSE_WINDOW
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Dec 05, 2005
- 553 views
cklester wrote: > > Matt Lewis wrote: > > > wxEVT_CLOSE_WINDOW should work. The following 'works' for me: <snip> > I expect a console to pop up here when I click the 'X' in the title bar to > close the app, but all that happens is the program closes. I don't get the > expected error message about dividing by zero. Yeah, that's what it does for me. What platform are you running? Matt Lewis
5. Re: wxEuphoria wxEVT_CLOSE_WINDOW
- Posted by cklester <cklester at yahoo.com> Dec 05, 2005
- 544 views
Matt Lewis wrote: > cklester wrote: > > I expect a console to pop up here when I click the 'X' in the title bar to > > close the app, but all that happens is the program closes. I don't get the > > expected error message about dividing by zero. > Yeah, that's what it does for me. What platform are you running? Windows XP Pro today (at work). Windows 2000 last night (at home). -=ck "Programming in a state of Euphoria." http://www.cklester.com/euphoria/
6. Re: wxEuphoria wxEVT_CLOSE_WINDOW
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Dec 05, 2005
- 562 views
cklester wrote: > > Matt Lewis wrote: > > cklester wrote: > > > I expect a console to pop up here when I click the 'X' in the title bar to > > > close the app, but all that happens is the program closes. I don't get the > > > expected error message about dividing by zero. > > Yeah, that's what it does for me. What platform are you running? > > Windows XP Pro today (at work). Windows 2000 last night (at home). Whoops, you're right. I was messing around with the new_wxFrame(), and had commented out the:
set_event_handler( this, get_id(this), wxEVT_CLOSE_WINDOW, routine_id("OnCloseWindow"))
...This is there to avoid forcing you to do it yourself. I'll think about the solution. For the time being, you can comment that out yourself, and it will work. Matt Lewis
7. Re: wxEuphoria wxEVT_CLOSE_WINDOW
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Dec 05, 2005
- 571 views
- Last edited Dec 06, 2005
Matt Lewis wrote: > > cklester wrote: > > > > I'm trying to trap the close window event when the user clicks the > > upper-right > > 'X' on the title bar. I can't seem to do it! Here's my procedure: > > > > procedure byebye( atom this, atom event_type, atom id, atom event ) > > save_plan() > > exit_main() > > end procedure > > set_event_handler( frame_Main, wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, > > routine_id("byebye")) > > set_event_handler( frame_Main, -1, wxEVT_CLOSE_WINDOW, routine_id("byebye")) > > > > The menu one works fine, but not the wxEVT_CLOSE_WINDOW one. I've researched > > this in the forum history and in the docs/demos, but I can't find an > > example. > Try changing the id from -1 to get_id(frame_Main) in the call to set_event_handler() and it should work. The problem is that the frame has an automatic handler set up with its id. (This all has to do with the way wxWidgets deals with events under the hood.) You then set up a handler with the 'wildcard' id of -1. When the event is triggered, wxEuphoria knows that the real id should be the frame's id. When it searches for the correct routine to call, it finds one listed under the correct id, and calls it. If it hadn't found that, it would call the default -1 routine. By using the actual id, you override the original event handler. For the next version of wxEuphoria, I'll change the automatic handler to use -1 for the id, so it won't be an issue. Matt Lewis