Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FXRuby question

0 views
Skip to first unread message

Rich Kilmer

unread,
Dec 5, 2002, 6:50:22 PM12/5/02
to
Does anyone know how to capture the event generated when one clicks on
the X button in the uppper right corner? I want to perform some
verifications and cleanup prior to closing.

Thanks,

Rich

_______________________________
Rich Kilmer, InfoEther LLC
trap("SIGINT") { raise [104, 101, 108, 108].pack("cccc") }

Lyle Johnson

unread,
Dec 5, 2002, 7:26:19 PM12/5/02
to
Rich Kilmer wrote:

> Does anyone know how to capture the event generated when one clicks on

> the X button in the upper right corner? I want to perform some


> verifications and cleanup prior to closing.

When you click the kill button on the main window, it (the FXMainWindow
object) first sends a SEL_CLOSE message to its message target, if any.
If that target handles the message then life goes on (i.e. the
application doesn't shut down). If the main window doesn't have a
message target, or if it does but the target doesn't handle the
SEL_CLOSE message, then the main window sends a SEL_COMMAND message
(with identifier FXApp::ID_QUIT) to the application (FXApp) object. And
that more or less terminates the main FOX event loop.

So for what you're describing, I think I'd try something like this:

theMainWindow.connect(SEL_CLOSE) do
# Do fun things
verify_things
clean_up_things

if ok_to_quit?

# All is well to shut down, so go ahead
# and send the ID_QUIT message to the
# application.

theMainWindow.app.handle(theMainWindow,
MKUINT(FXApp::ID_QUIT, SEL_COMMAND), nil)
else

# We've decided not to shut down after all

end
end

Hope this helps,

Lyle


Rich Kilmer

unread,
Dec 5, 2002, 10:23:11 PM12/5/02
to
That solved my problem perfectly. The FreeRIDE project thanks you ;-)

-rich

0 new messages