Notifications
Clear all

[Closed] Checkbox.state not changing?

Quick Question…

If I have a checkbox in a rollout with a button that is pressed, which is designed to invert the state of the checkbox no matter whether the checkbox is ticked ON or OFF, why does the following code not work?

on SelectInvert pressed do
(
if cb_wrl.state = true then
(
cb_wrl.checked = false
)
else cb_wrl.checked = true
)

Thanks,

Mike

2 Replies

Equality in a if statement is == and not just =:

on SelectInvert pressed do
(
	if cb_wrl.state == true then
	(
		 cb_wrl.checked = false
	)
	else
	(
		cb_wrl.checked = true
	)
)

A better approach is to negate the previous state:

on SelectInvert pressed do
(
	cb_wrl.state = not cb_wrl.state
)
 JHN

I also think it’s better to post on 1 forum at a time, this is wasting peoples time really… If you don’t get your answers on one forum then posting after a while on the other (the area) would be fine, but posting twice is imho not a “good” thing to do.

-Johan