hey, i want to make an option menu when the first list is selected, the
second will be filled.
the first list contains a list of clients
the second list contains all locations of the selected client
this is my code:
Making the client list
# Second row
FXLabel.new(matrix, "Client")
# Popup menu
clientPane = FXPopup.new(self)
FXOption.new(clientPane, "Select a client" , nil, nil, 0,
JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
@clients = @driver.FetchClients(@@twa, @user.id)
for client in @clients
FXOption.new(clientPane, client.name , nil, nil, 0,
JUSTIFY_HZ_APART|ICON_AFTER_TEXT).connect(SEL_COMMAND) {
getGeotagsByClient() }
end
# Option menu
@clientMenu = FXOptionMenu.new(matrix, clientPane,
(FRAME_RAISED|FRAME_THICK|
JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_RIGHT|LAYOUT_CENTER_Y))
Making the location list (just shows "Select a client first")
# Third row
FXLabel.new(matrix, "Geotag")
# Popup menu
geotagPane = FXPopup.new(self)
FXOption.new(geotagPane, "Select a client first", nil, nil, 0,
JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
# Option menu
@geotagMenu = FXOptionMenu.new(matrix, geotagPane,
(FRAME_RAISED|FRAME_THICK|
JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_RIGHT|LAYOUT_CENTER_Y))
when i select an item in the first list the getGeotagsByClient() is
actived.
def getGeotagsByClient()
getApp().beginWaitCursor() do
current_option = @clientMenu.getCurrentNo()
current_client_id = @clients[current_option-1].id
pane = FXPopup.new(self)
geotags = @driver.FetchGeotagsByClient(@@twa, @user.id,
current_client_id)
test = ""
for geotag in geotags
FXOption.new(pane, geotag.address1 + ", " + geotag.address2 +
", " +
geotag.floor, nil, nil, 0, JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
test += geotag.address1 + "\n "
end
@testing.text = test
@geotagMenu.menu = pane
end
end
here the second list should be filled but isnt.
"@testing" contains all the locations => CORRECT
" @geotagMenu" only contains the first item, no the whole list
Can some help me?
Thanks in adance
Nick
hey,
this is a little update
i want to make an option menu when the first list is selected, the second will
be filled.
the first list contains a list of clients
the second list contains all locations of the selected client
this is my code:
Making the client list
# Second row
FXLabel.new(matrix, "Client")
# Popup menu
clientPane = FXPopup.new(self)
#Connect to webservice (FetchClients)
@clients = @driver.FetchClients(@@twa, @user.id)
for client in @clients
FXOption.new(clientPane, client.name , nil, nil, 0,
JUSTIFY_HZ_APART|ICON_AFTER_TEXT).connect(SEL_COMMAND) { getGeotagsByClient() }
end
# Option menu
@clientMenu = FXOptionMenu.new(matrix, clientPane, (FRAME_RAISED|FRAME_THICK|
JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_RIGHT|LAYOUT_CENTER_Y))
Making the location list (first time, locations from first client)
# Third row
FXLabel.new(matrix, "Geotag")
# Popup menu
geotagPane = FXPopup.new(self)
#Connect to webservice (FetchGeotagsByClient)
@geotags = @driver.FetchGeotagsByClient(@@twa, @user.id, @clients[0].id)
for geotag in @geotags
FXOption.new(geotagPane, geotag.address1 + ", " + geotag.address2
+ ", " + geotag.floor, nil, nil, 0, JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
end
# Option menu
@geotagMenu = FXOptionMenu.new(matrix, geotagPane, (FRAME_RAISED|FRAME_THICK|
JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_RIGHT|LAYOUT_CENTER_Y))
when i select an item in the first list the getGeotagsByClient() is actived.
def self.getGeotagsByClient()
getApp().beginWaitCursor() do
current_option = @clientMenu.getCurrentNo()
current_client_id = @clients[current_option].id
pane = FXPopup.new(self, (FRAME_RAISED|FRAME_THICK|
JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_RIGHT|LAYOUT_CENTER_Y))
#Connect to webservice (FetchGeotagsByClient)
@geotags = @driver.FetchGeotagsByClient(@@twa, @user.id, current_client_id)
test = ""
for geotag in @geotags
FXOption.new(pane, geotag.address1 + ", " + geotag.address2 +
", " + geotag.floor, nil, nil, 0, JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
test += geotag.address1 + "\n "
end
@user_text.text = test
@geotagMenu.menu = pane
@geotagMenu.setCurrentNo(2)
end
end
here the second list should be filled but isnt.
"@testing" contains all the locations => CORRECT
" @geotagMenu" only contains the one item (selects the 3rd, no the
whole list)
Can some help me?
Thanks in adance
Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/fxruby-users/attachments/20060201/039586eb/attachment.htm
On Wed, 01 Feb 2006 18:01:19 +0000, "Nick Brutyn" <brutyn_nick at hotmail.com> wrote :> when i select an item in the first list the getGeotagsByClient() is > actived. > > def getGeotagsByClient() > getApp().beginWaitCursor() do > current_option = @clientMenu.getCurrentNo() > current_client_id = @clients[current_option-1].id > pane = FXPopup.new(self) > geotags = @driver.FetchGeotagsByClient(@@twa, @user.id, > current_client_id) > test = "" > for geotag in geotags > FXOption.new(pane, geotag.address1 + ", " + geotag.address2 + ", " + > geotag.floor, nil, nil, 0, JUSTIFY_HZ_APART|ICON_AFTER_TEXT) > test += geotag.address1 + "\n " > end > @testing.text = test > @geotagMenu.menu = pane > end > end > > here the second list should be filled but isnt. > "@testing" contains all the locations => CORRECT > " @geotagMenu" only contains the first item, no the whole list > > Can some help me?What happens if you add a call to pane.create after you''ve added all of the items: for geotag in geotags FXOptionMenu.new(pane, ...) end pane.create # <------- add this here @geotag.menu = pane -- Lyle
Thanks that worked fine. ----- Original Message ----- From: <lyle at knology.net> To: <brutyn_nick at hotmail.com> Cc: <fxruby-users at rubyforge.org> Sent: Wednesday, February 01, 2006 7:05 PM Subject: Re: [fxruby-users] Option Menu help> > On Wed, 01 Feb 2006 18:01:19 +0000, "Nick Brutyn" > <brutyn_nick at hotmail.com> > wrote : > >> when i select an item in the first list the getGeotagsByClient() is >> actived. >> >> def getGeotagsByClient() >> getApp().beginWaitCursor() do >> current_option = @clientMenu.getCurrentNo() >> current_client_id = @clients[current_option-1].id >> pane = FXPopup.new(self) >> geotags = @driver.FetchGeotagsByClient(@@twa, @user.id, >> current_client_id) >> test = "" >> for geotag in geotags >> FXOption.new(pane, geotag.address1 + ", " + geotag.address2 + ", " + >> geotag.floor, nil, nil, 0, JUSTIFY_HZ_APART|ICON_AFTER_TEXT) >> test += geotag.address1 + "\n " >> end >> @testing.text = test >> @geotagMenu.menu = pane >> end >> end >> >> here the second list should be filled but isnt. >> "@testing" contains all the locations => CORRECT >> " @geotagMenu" only contains the first item, no the whole list >> >> Can some help me? > > What happens if you add a call to pane.create after you''ve added all of > the > items: > > for geotag in geotags > FXOptionMenu.new(pane, ...) > end > pane.create # <------- add this here > @geotag.menu = pane > > -- Lyle >