I wrote something like that once…
try (destroyDialog LightSwitch) catch ()
rollout lightSwitch "LightSwitch"
(
button lightsOn "Lights On" pos:[5,10]
button lightsOff "Lights Off" pos:[90,10]
on lightsOn pressed do
(
if $ != undefined then
(
for l in $ where superClassOf l == light do
(
if isProperty l #on then l.on = true
if isProperty l #enabled then l.enabled = true
)
)
)
on lightsOff pressed do
(
if $ != undefined then
(
for l in $ where superClassOf l == light do
(
if isProperty l #on then l.on = false
if isProperty l #enabled then l.enabled = false
)
)
)
)
createDialog lightSwitch