Notifications
Clear all
[Closed] button state in toolbar
Mar 24, 2011 2:15 pm
Hi folks!
I got an idea on how to have more control of the state of objects they’re in, e.g. 5 boxes with $.backfacecull = on already set.
A button in my toolbar should tell me if backface culling is active on all those objects in my scene or not and should be displayed ‘pressed’ or respectively ‘released’.
How can I achieve this?
best regards,
toby
3 Replies
1 Reply
/* by denisT */
macroScript BackFace_Cull_Mode
buttonText:"BackFace"
category:"Custom"
tooltip:"BackFace Cull Mode Control"
icon:#("SubObjectIcons",4)
(
local state = off
on isChecked do
(
state = off
for n in selection while not state do state = n.backFaceCull
state
)
on isEnabled do (selection.count > 0)
on execute do if selection.count > 0 do selection.backFaceCull = (state = not state)
)
Mar 24, 2011 2:15 pm
Like this?
(
rollout frmMain "Button States"
(
checkbutton chkStates "Backface Cull"
on frmMain open do
(
bStates = for i in selection where i.backFaceCull == true collect i
if bStates.count == selection.count then chkStates.state = true
)
)
createDialog frmMain
)
Mar 24, 2011 2:15 pm
And a better version, using nodeeventcallback, toggles the button while you select different objects, remember if you have a selection of 5 objects and one of them has backfacecull disabled the button will also be disabled. It will only be enabled if ALL objects selected have backfacecull on.
(
rollout frmMain "Button States"
(
checkbutton chkStates "Backface Cull"
local callbackItem
fn checkStates =
(
if selection.count != 0 then
(
bStates = for i in selection where i.backFaceCull == true collect i
if bStates.count == selection.count then chkStates.state = true else chkStates.state = false
)
)
fn selCallback ev nd =
(
checkStates()
)
on frmMain open do
(
checkStates()
callbackItem = NodeEventCallback mouseUp:true selectionchanged:selCallback
)
on frmMain close do
(
callbackItem = undefined
gc light:true
)
)
createDialog frmMain
)