FXMessageBox - basics


#1

I am just learning Ruby/FXRuby basics and am struggling trying to
capture the return value from an FXMessageBox. The following snippet of
code (copied/modified from the web) causes the app to crash. The app
generally works and clicking ‘Message Box 2’, which handler excludes
references to ‘response’, runs without problem (though does nothing
useful). Any clues as to what I’m doing wrong (debugging isn’t working
for me yet, either)? Thanks for any help in advance.

David

msgbox_1_cmd = FXMenuCommand.new(msgbox_menu, “Message Box &1”)
msgbox_1_cmd.connect(SEL_COMMAND) do
response = FXMessageBox.new( self,
“Message Box 1”,
“This is Message Box 1”,
nil,
MBOX_OK_CANCEL|DECOR_TITLE|DECOR_BORDER)
response.execute PLACEMENT_OWNER

if MBOX_CLICKED_OK == response
FXMessageBox.new( self,
“Message Box 1 Result”,
“You clikced ‘OK’”,
nil,
MBOX_OK_CANCEL|DECOR_TITLE|DECOR_BORDER)
return 1
else
FXMessageBox.new( self,
“Message Box 1 Result”,
“You clikced ‘Cancel’”,
nil, MBOX_OK_CANCEL|DECOR_TITLE|DECOR_BORDER)
return 1
end
end


#2

Hi there David,
I use foxGUIb for my GUI stuff so take what i say as you wish.

When I played with dialog boxes I had to create a class or create an
instance variable and make reference through that SO…

what is the value reported to be in response? could it be MBOX_OKAY?
and is MBOX_OKAY equal in value to MBOX_OK_CLICKED?

I’ve not run you’re program at all just hoped this might help you.

dave.

David Mccrea wrote:

I am just learning Ruby/FXRuby basics and am struggling trying to
capture the return value from an FXMessageBox. The following snippet of
code (copied/modified from the web) causes the app to crash. The app
generally works and clicking ‘Message Box 2’, which handler excludes
references to ‘response’, runs without problem (though does nothing
useful). Any clues as to what I’m doing wrong (debugging isn’t working
for me yet, either)? Thanks for any help in advance.

David

msgbox_1_cmd = FXMenuCommand.new(msgbox_menu, “Message Box &1”)
msgbox_1_cmd.connect(SEL_COMMAND) do
response = FXMessageBox.new( self,
“Message Box 1”,
“This is Message Box 1”,
nil,
MBOX_OK_CANCEL|DECOR_TITLE|DECOR_BORDER)
response.execute PLACEMENT_OWNER

if MBOX_CLICKED_OK == response
FXMessageBox.new( self,
“Message Box 1 Result”,
“You clikced ‘OK’”,
nil,
MBOX_OK_CANCEL|DECOR_TITLE|DECOR_BORDER)
return 1
else
FXMessageBox.new( self,
“Message Box 1 Result”,
“You clikced ‘Cancel’”,
nil, MBOX_OK_CANCEL|DECOR_TITLE|DECOR_BORDER)
return 1
end
end