ScriptSpot

Forum topic · General Scripting

activating button in script from script

By kredka · 2013-12-09

Description

I have smpile problem but none of my ideas won't work.
How to activate button(make it execute) in my rollout by another buttion.
Bellow example, btn6 should activate btn5, I already try with .checked=true, state=true, enabled= true but it don't work and I have to press and execute button:

rollout unnamedRollout "Untitled" width:162 height:300
(
button btn5 "messagebox" pos:[28,28] width:90 height:30
button btn6 "accesor" pos:[36,79] width:84 height:38
on btn5 pressed do
(

messagebox "it work"

)
on btn6 pressed do
(
UIAccessor.PressButton btn5 -- press the button
)
)
createdialog unnamedRollout

Comments (3)

Thank You

kredka · 2013-12-09

Great, thank You, work perfect.

barigazy · 2013-12-09

Most important thing here is to declare your tool variable as global


global unnamedRollout
-- close tool if is alreday opened
try(destroyDialog unnamedRollout)catch()

or in one line with "::"


try(destroyDialog ::unnamedRollout)catch()

Now your code need to look like this

try(destroyDialog ::unnamedRollout)catch()
rollout unnamedRollout "Untitled" width:162 height:300
(
button btn5 "messagebox" pos:[28,28] width:90 height:30
button btn6 "accesor" pos:[36,79] width:84 height:38
on btn5 pressed do
(
messagebox "it work"
)
on btn6 pressed do
(
unnamedRollout.btn5.pressed() -- press the button
)
)
createdialog unnamedRollout 162 300 10 110 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

*

Rodman · 2013-12-09

What do you want to achieve with this ?