Re: wxEuphoria wxEVT_CLOSE_WINDOW

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

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

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

Search



Quick Links

User menu

Not signed in.

Misc Menu