Notifications
Clear all

[Closed] Persistent when construct

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
(@heilandzack)
Joined: 11 months ago

Posts: 0

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

 lo1

When do you choose to use the node event system vs. general event #selectionSetChanged callback? Is one more efficient than the other?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

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

 lo1

Makes sense.

Page 2 / 2