Notifications
Clear all
[Closed] Persistent when construct
Page 2 / 2
Prev
Apr 15, 2015 7:46 am
something like this:
global WhenSelectMonitor
(
struct WhenSelectMonitorStruct
(
eventCallback,
WhenSelect =
(
attributes WhenSelect attribID:#(1234567, 7654321)
(
fn getNode = if (owner = custattributes.getowner this) != undefined do refs.dependentnodes owner firstonly:on
fn onOwnerSelected node: =
(
if node == unsupplied do node = getNode()
if isvalidnode node do
(
format "node:% selected:%
" node node.isselected
)
)
parameters params
(
)
rollout params "When Select"
(
)
)
),
fn hasWhenSelect node = isvalidnode node and
(
custattributes.get node.baseobject this.WhenSelect != undefined
),
fn onSelectionChanged event handles =
(
for handle in handles do
(
node = getAnimByHandle handle
if ::WhenSelectMonitor.hasWhenSelect node do
(
node.WhenSelect.onOwnerSelected node:node
)
)
),
on create do
(
eventCallback = NodeEventCallback selectionChanged:onSelectionChanged
)
)
WhenSelectMonitor = WhenSelectMonitorStruct()
)
delete objects
b = box()
attr = createinstance WhenSelectMonitor.WhenSelect
append b.baseobject.custattributes attr
1 Reply
Hm , i think that’s a bit too advanced for me. Gonna stick to the solution before, anyway thank you for the snippet, I’ll try it out
Apr 15, 2015 7:46 am
When do you choose to use the node event system vs. general event #selectionSetChanged callback? Is one more efficient than the other?
1 Reply
i need what was selected or deselected in my case. callback notification is undefined for #selectionSetChanged
also it’s easier to on/off (enable/disable) node event callback when it’s needed
Page 2 / 2
Prev