Notifications
Clear all

[Closed] Checkbutton change state question- pressing checkbutton automatically?

Hi,
I have a question about running checkbutton,I want to run functions after changing the state of checkbutton,generally,we can do it like :

rollout only_test "" 
(
    checkbutton chk_test "Check Me!" 
    on chk_test changed state do 
    (
		print "Is changing state..."
    )
)
createDialog only_test 

So my question is ,how can I print “Is changing state…” without pressing the checkbutton but the codes can execute and checkbutton also change its state at the same time?
I tried this way,but only the state can change,no codes executed.

rollout only_test "" 
(
    checkbutton chk_test "Check Me!" 
    on chk_test changed state do 
    (
		print "Is changing state..."
	)
)
createDialog only_test 

only_test.chk_test.checked=true

or

rollout only_test "" 
(
    checkbutton chk_test "Check Me!" 
    on chk_test changed state do 
    (
		print "Is changing state..."
	)
)
createDialog only_test 

only_test.chk_test.checked=true
only_test.chk_test.checked=false

any suggestions?

2 Replies
only_test.chk_test.changed (val=(only_test.chk_test.checked=true))

or

only_test.chk_test.changed (val=(only_test.chk_test.checked=not only_test.chk_test.checked))

First one sets it to what you tell it; true or false.
Second one sets it to the opposite of whatever it’s current state is.

1 Reply
(@momo2012)
Joined: 11 months ago

Posts: 0

Too much thanks Pacermike,it works.