Exiting a DialogBox created with FoxGUIb

Dear All

I am new to FOX and FoxGUIb. I have found FoxGUIb very
useful and I have created an application with menus,
one of which calls a DialogBox for the user to enter
some values. After finishing the user will press OK to
save data.

Unfortunately I don’t know how to let the
DialogBox know tha tonce the OK button is pressed it
should exit. It seems I need to send message ID_ACCEPT
to some recipient (not sure which) when the button OK
is clicked? But no idea how to do that with the code
that is generated by FoxGUIb as the button is created
in a different way to what I have seen in the examples
in the web, and I have no idea how to relate them (
I’m afraid I haven’t really understood the FXButton
API)

The dialog box examples I have seen do something like
the following:

Accept

accept = FXButton.new(buttons, "&Accept", nil,

self, ID_ACCEPT,
FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)

However the FoxGUIb creates a button doing:

FX::Button.new(@verticalframe7){|w|
@button_ok=w
w.wdg_name=‘button_ok’
w.text=“Ok”
w.width=21
w.y=4
w.height=21
w.layoutHints=40
w.x=26
w.selector=FX::DialogBox::ID_QUIT

            @button_ok.connect(Fox::SEL_COMMAND){
                        lat = textfield_lat.text
                        lon = textfield_lon.text
                        heading

=textfield_heading.text
#How
do I indicate that I want to accept and exit?:?

            }

}

So in this last example, how do I exit the dialog when
button is clicked?

Thanks very much for your help
Eduardo

Send instant messages to your online friends

On 12/8/06, e aldaz [email protected] wrote:

should exit. It seems I need to send message ID_ACCEPT
to some recipient (not sure which) when the button OK
is clicked? But no idea how to do that with the code
that is generated by FoxGUIb as the button is created
in a different way to what I have seen in the examples
in the web, and I have no idea how to relate them (
I’m afraid I haven’t really understood the FXButton
API)

me neither :wink: … there are some very hackish things that make the use
of fox toolkit not as easy as it could be.

However the FoxGUIb creates a button doing:
w.selector=FX::DialogBox::ID_QUIT
}

So in this last example, how do I exit the dialog when
button is clicked?

the most simple aproach would be like this:
@button_ok.connect(Fox::SEL_COMMAND){

@topwin.hide() # assuming that @topwin is the name of the dialogbox
}

however if your dialog box has been run modal this will not work. the
dialog box disappears but is still modal. in this case you have to
send an ID_ACCEPT message to @topwin like this:

@topwin.handle(@button, FXSEL(Fox::SEL_COMMAND,
Fox::FXDialogBox::ID_ACCEPT), nil)

hope this helps,
– meinrad (henon)

Hi Meinrad,
Thank you very much for your help.
Where would i put the message handler:
@topwin.handle(@button,
FXSEL(Fox::SEL_COMMAND,Fox::FXDialogBox::ID_ACCEPT),
nil)
Would i put it inside the button_ok.connect method?

FX::Button.new(@verticalframe7){|w|
@button_ok=w
w.wdg_name=‘button_ok’
w.text=“Ok”
w.width=21
w.y=4
w.height=21
w.layoutHints=40
w.x=26
w.selector=FX::DialogBox::ID_QUIT

             @button_ok.connect(Fox::SEL_COMMAND){
             lat = textfield_lat.text
             lon = textfield_lon.text
             heading =textfield_heading.text
             @topwin.handle(@button,

FXSEL(Fox::SEL_COMMAND,Fox::FXDialogBox::ID_ACCEPT),
nil)
}
}

Thanks again!
Eduardo

— Meinrad R. [email protected] wrote:

OK to
code
me neither :wink: … there are some very hackish things

self, ID_ACCEPT,

FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)

            w.height=21
                        heading

button is clicked?
dialog box disappears but is still modal. in this
Eduardo


The all-new Yahoo! Mail goes wherever you go - free your email address
from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html

On 12/9/06, e aldaz [email protected] wrote:

Hi Meinrad

I have included the call you mentioned in the funcion
connect and i get the error:

@topwin.handle(@button, FXSEL(Fox::SEL_COMMAND,
Fox::FXDialogBox::ID_ACCEPT), nil)

undefined method `FXSEL’ for #DialogBox:0x7f5e230

yeah, sorry, i forgot to prefix FXSEL with Fox:: like this:

@topwin.handle(@button_ok,
Fox::FXSEL(Fox::SEL_COMMAND,Fox::FXDialogBox::ID_ACCEPT), nil)

– meinrad

Hi Meinrad

I have included the call you mentioned in the funcion
connect and i get the error:

@topwin.handle(@button, FXSEL(Fox::SEL_COMMAND,
Fox::FXDialogBox::ID_ACCEPT), nil)

undefined method `FXSEL’ for #DialogBox:0x7f5e230

I have also seen mention of using something like:
getApp().stopModal(@topwin, 1)
@topwin.hide
But didn’t work for me either
I have included all the code created by the FoxGUIb,
hoping it could make things clearer.

Thanks again !
Eduardo

source generated by foxGUIb 0.7.1

class DialogBox
def initialize( parent)
construct_widget_tree( parent)
init if respond_to? ‘init’
end

def construct_widget_tree( parent)
	@topwin=
	FX::DialogBox.new(parent){|w|
		@dialogBox=w
		w.wdg_name='dialogBox'
		w.width=137
		w.shown=true
		w.y=472
		w.height=125
		w.title="TrackerPod Data"
		w.x=-543
		FX::HorizontalFrame.new(@dialogBox){|w|
			@horizontalframe3=w
			w.wdg_name='horizontalframe3'
			w.width=137
			w.height=30
			w.layoutHints=1536
			FX::Label.new(@horizontalframe3){|w|
				@label_dialog_title=w
				w.wdg_name='label_dialog_title'
				w.text="TRACKER POD DATA:"

w.font=FX::Font.new.from_s(‘Tahoma|100|70|5|0|0|0’).to_FXFont
w.width=137
w.y=5
w.height=20
w.layoutHints=40
}
}
FX::HorizontalFrame.new(@dialogBox){|w|
@horizontalframe2=w
w.wdg_name=‘horizontalframe2’
w.width=137
w.y=34
w.height=57
w.layoutHints=1024
FX::VerticalFrame.new(@horizontalframe2){|w|
@verticalframe4=w
w.wdg_name=‘verticalframe4’
w.width=56
w.height=57
FX::Label.new(@verticalframe4){|w|
@label_lat=w
w.wdg_name=‘label_lat’
w.text=“Lat:”
w.width=23
w.height=17
}
FX::Label.new(@verticalframe4){|w|
@label_lon=w
w.wdg_name=‘label_lon’
w.text=“Lon:”
w.width=25
w.y=17
w.height=17
}
FX::Label.new(@verticalframe4){|w|
@label_heading=w
w.wdg_name=‘label_heading’
w.text=“Heading:”
w.width=47
w.y=34
w.height=17
}
}
FX::VerticalFrame.new(@horizontalframe2){|w|
@verticalframe6=w
w.wdg_name=‘verticalframe6’
w.width=81
w.height=57
w.x=56
FX::TextField.new(@verticalframe6){|w|
@textfield_lat=w
w.wdg_name=‘textfield_lat’
w.width=66
w.height=19
w.numColumns=10
}
FX::TextField.new(@verticalframe6){|w|
@textfield_lon=w
w.wdg_name=‘textfield_lon’
w.width=66
w.y=19
w.height=19
w.numColumns=10
}
FX::TextField.new(@verticalframe6){|w|
@textfield_heading=w
w.wdg_name=‘textfield_heading’
w.width=66
w.y=38
w.height=19
w.numColumns=10
}
}
}
FX::HorizontalFrame.new(@dialogBox){|w|
@horizontalframe4=w
w.wdg_name=‘horizontalframe4’
w.width=137
w.y=95
w.height=30
w.layoutHints=3584
FX::VerticalFrame.new(@horizontalframe4){|w|
@verticalframe7=w
w.wdg_name=‘verticalframe7’
w.width=47
w.height=30
FX::Button.new(@verticalframe7){|w|
@button_ok=w
w.wdg_name=‘button_ok’
w.text=“Ok”
w.width=21
w.y=4
w.height=21
w.layoutHints=40
w.x=13
@button_ok.connect(Fox::SEL_COMMAND){
lat = textfield_lat.text
lon = textfield_lon.text
heading = textfield_heading.text
#No idea how to close the window. something
about ID_ACCEPT

#@topwin.handle(nil,MKUINT(w::ID_ACCEPT,SEL_COMMAND),nil)
#@topwin.handle(@button_ok,
FXINT(Fox::SEL_COMMAND,Fox::FXDialogBox::ID_ACCEPT),
nil)

@topwin.handle(@button_ok,
FXSEL(Fox::SEL_COMMAND,Fox::FXDialogBox::ID_ACCEPT),
nil)
#getApp().stopModal(@topwin, 1)
#@topwin.hide

					}
				}
			}
			FX::VerticalFrame.new(@horizontalframe4){|w|
				@verticalframe9=w
				w.wdg_name='verticalframe9'
				w.width=90
				w.height=30
				w.x=47
				FX::Button.new(@verticalframe9){|w|
					@button_cancel=w
					w.wdg_name='button_cancel'
					w.text="Cancel"
					w.width=40
					w.y=4
					w.height=21
					w.layoutHints=40
					w.x=25
				}
			}
		}
	}
end
attr_reader :topwin
attr_reader :dialogBox
attr_reader :horizontalframe3
attr_reader :label_dialog_title
attr_reader :horizontalframe2
attr_reader :verticalframe4
attr_reader :label_lat
attr_reader :label_lon
attr_reader :label_heading
attr_reader :verticalframe6
attr_reader :textfield_lat
attr_reader :textfield_lon
attr_reader :textfield_heading
attr_reader :horizontalframe4
attr_reader :verticalframe7
attr_reader :button_ok
attr_reader :verticalframe9
attr_reader :button_cancel

end

#unit test
if FILE==$0
require ‘libGUIb16’
app=FX::App.new
w=DialogBox.new app
w.topwin.show(Fox::PLACEMENT_SCREEN)
app.create
app.run
end


All new Yahoo! Mail “The new Interface is stunning in its simplicity and
ease of use.” - PC Magazine
http://uk.docs.yahoo.com/nowyoucan.html

Meinrad, it works perfectly, thank you very much

— Meinrad R. [email protected] wrote:

undefined method `FXSEL’ for
#DialogBox:0x7f5e230

yeah, sorry, i forgot to prefix FXSEL with Fox::
like this:

@topwin.handle(@button_ok,

Fox::FXSEL(Fox::SEL_COMMAND,Fox::FXDialogBox::ID_ACCEPT),

nil)

– meinrad


All new Yahoo! Mail “The new Interface is stunning in its simplicity and
ease of use.” - PC Magazine
http://uk.docs.yahoo.com/nowyoucan.html