View Full Version : How can I call a button with a variable ?
cleobule 10-27-2009, 02:30 PM Hello,
With different buttons of a rollout :
button bu1 "blabla"
button bu2 "bloblo"
etc..
I would like to make liste
ListButton = #("bu1","bu2",..)
and then being able to do something which would work like this ;
ListButton[1].caption = "Blabla2"
(I would I like to do the same thing with the state of radiobuttons)
Is it possible ? Does anyone know how to do this ?
Thank you in advance
Daniel
|
|
bkravi
10-27-2009, 02:45 PM
rollout test "TEST"
(
button bu1 "blabla"
button bu2 "bloblo"
button changeName "Change Name"
local ListButton = (for r in test.controls where classof r == ButtonControl collect r)
on changeName pressed do (ListButton[1].caption = "Blabla2")
)
createdialog test 200
you can use any control type and can also test controls by there names while collecting them in ListButton array.
R
cleobule
10-27-2009, 05:33 PM
It works. Exactly what I needed. Thank you.
denisT
10-27-2009, 06:11 PM
Hello,
With different buttons of a rollout :
button bu1 "blabla"
button bu2 "bloblo"
etc..
I would like to make liste
ListButton = #("bu1","bu2",..)
and then being able to do something which would work like this ;
ListButton[1].caption = "Blabla2"
(I would I like to do the same thing with the state of radiobuttons)
Is it possible ? Does anyone know how to do this ?
Thank you in advance
Daniel
try(destroydialog test_rol) catch()
rollout test_rol "check buttons list"
(
group "Check Buttons: "
(
checkbutton ch1 "" width:170
checkbutton ch2 "" width:170
checkbutton ch3 "" width:170
checkbutton ch4 "" width:170
)
button rename "Rename" width:170 offset:[0,4]
local names = #("May", "April", "June", "July")
local chs = #(ch1,ch2,ch3,ch4) -- it should be pointers to control - NOT NAMES
on rename pressed do
(
new = copy names #nomap
for k=1 to chs.count do
(
id = random 1 new.count
chs[k].caption = new[id]
chs[k].state = ((random 0 1) == 0)
deleteitem new id
)
)
on test_rol open do for k=1 to chs.count do chs[k].caption = names[k]
)
createdialog test_rol width:200 height:170
ehulser
10-30-2009, 09:10 PM
You can also use getProperty on a rollout
rollout roll "Test" (
button uiTestBTN "Test"
button uiTest2BTN "Test"
button uiTest3BTN "Test"
function setTitles widgets title = (
for n in widgets do (getProperty roll n).caption = title
)
on uiTestBTN pressed do ( roll.setTitles #( #uiTestBTN, #uiTest2BTN ) "Button 01" )
on uiTest2BTN pressed do ( roll.setTitles #( #uiTest2BTN, #uiTest3BTN ) "Button 02" )
on uiTest3BTN pressed do ( roll.setTitles #( #uiTestBTN, #uiTest2BTN, #uiTest3BTN ) "Button 03" )
)
createDialog roll
Light
10-30-2009, 10:03 PM
Hi,
If you want to loop through all the controls and filter them by type, use the Controls property on the rollout:
for control in rollout.Controls where ClassOf control == ButtonControl do Print control.Name
Light
CGTalk Moderation
10-30-2009, 10:03 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.