J
John Reed
This suggestion was posted by Lyle some time ago:
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
I see what you did in the above example, and I'm trying to do the same
thing in my code without much luck.
Here's how my class is defined:
class DataTable < FXMainWindow
And 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 because
if the dialog box used in the program for data entry is open, and
there have been changes, I want to warn the user about those changes.
I tried attaching the .connect(SEL_CLOSE) to the contents object, but
that didn't work.
Thanks for the help,
John Reed
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
I see what you did in the above example, and I'm trying to do the same
thing in my code without much luck.
Here's how my class is defined:
class DataTable < FXMainWindow
And 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 because
if the dialog box used in the program for data entry is open, and
there have been changes, I want to warn the user about those changes.
I tried attaching the .connect(SEL_CLOSE) to the contents object, but
that didn't work.
Thanks for the help,
John Reed