[wxruby-users] How to set exit on close??

Alex Fenton alex at pressure.to
Thu Mar 6 11:34:12 EST 2008


Pat Kiatchaipipat wrote:
> I want to set close window when press 'X' in top-right I make wxruby GUI
> from Farpy guie but I can't close it (when I close I must press close in
> cmd and the return -1) how can I set it??
I'm not sure I understand your question. Basically, if you want to have 
the standard close button close a window, do nothing. By default, wxRuby 
understands that the "X" button should close the window.

If you want to do some custom checking or processing when the close 
button on frame is pressed, use evt_close to define an event handler for 
the frame.

evt_close :on_close

Then in your on_close method, receive the event, then either call skip() 
or veto() to allow or disallow the event.

def on_close(event)
  if ready_to_close
    event.skip()
  else
    event.veto()
  end
end

Take a look at the samples/minimal/minimal.rb as this is demonstrated in 
there

alex



More information about the wxruby-users mailing list