[Fxruby-users] FXRuby - SEL_CLOSE event
Status: Inactive
Brought to you by:
lyle
From: John R. <col...@ya...> - 2004-02-19 04:46:46
|
This suggestion was posted by Lyle (Google) some time ago:When you click the kill button on the main window, it (theFXMainWindowobject) 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.Andthat 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 endHope this helps,LyleI see what you did in the above example, and I'm trying to do the samething in my code without much luck.Here's how my class is defined:class DataTable < FXMainWindowAnd then my widgets are attached to this object: contents = FXVerticalFrame.new(self, LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y)Then the code is like this: frame = FXVerticalFrame.new(contents, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y) do |f| f.padLeft = 0 f.padRight = 0 f.padTop = 0 f.padBottom = 0 end # Table @@table = FXTable.new(frame, 20, 7, nil, 0, TABLE_COL_SIZABLE|TABLE_ROW_SIZABLE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 2,2,2,2)I don't know how to capture the SEL_CLOSE event in my program becauseif the dialog box used in the program for data entry is open, andthere have been changes, I want to warn the user about those changes.I tried attaching the .connect(SEL_CLOSE) to the contents object, butthat didn't work.Thanks for the help,John Reed --------------------------------- Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. |