[Closed] On Dialog Close?
Is there an easy way to execute a block of code when a dialog is closed or destroyed?
Also is there a safe, not performance destroying way to execute a bit of code everytime a specific node or couple of nodes are moved or deleted?
Do I use a callback for both of those? For the single node what would the callback event be?
Edit: I’ll be a bit more specific since that’s a bit vague.
I have a global variable which I want to be updated with the object’s current position whenever possible. Should I just do that through a position expression? But that would then control the object and it would be unmoveable … just thinking out loud here.
For dialogs, I don’t think there is any “global” way to track when they are closed. I tend to watch for the rollout close event and do my cleanup there
Also is there a safe, not performance destroying way to execute a bit of code everytime a specific node or couple of nodes are moved or deleted?
Do I use a callback for both of those? For the single node what would the callback event be?
Edit: I’ll be a bit more specific since that’s a bit vague.
I have a global variable which I want to be updated with the object’s current position whenever possible. Should I just do that through a position expression? But that would then control the object and it would be unmoveable … just thinking out loud here.
For a single node you could use
when <attribute> <objects> change[s] [ id:<name> ] [handleAt:#redrawViews|#timeChange] [ <object_parameter> ] do <expr>
(Thanks Bobo)
and
when <objects> deleted [ id:<name> ] [handleAt:#redrawViews|#timeChange] [ <object_parameter> ] do <expr>
Look up “Change Handlers” for more details on how to use it…
Just use the on <rollout> close event for when dialogs are closed. Since the dialog IS the rollout on a createDialog it’s the same thing.
Is there an easy way to execute a block of code when a dialog is closed or destroyed?
on rollout close do
(
)
Also is there a safe, not performance destroying way to execute a bit of code everytime a specific node or couple of nodes are moved or deleted?
Change handlers are probably the only way, unless you do some sort of script controller to check if somethings defined or not? Or check a weak reference? Change handlers are dangerous things – make sure you unregister it when you dont need it and give it an ID:#
Do I use a callback for both of those? For the single node what would the callback event be?
Just the second one
Edit: I’ll be a bit more specific since that’s a bit vague.
I have a global variable which I want to be updated with the object’s current position whenever possible. Should I just do that through a position expression? But that would then control the object and it would be unmoveable … just thinking out loud here.
Make a custom attribute paramblock (point3) and update it everytime the rollout closes?
on testRoll close do
(
testObject.pos.controller.'test attribs'.testval = testObject.pos
)
You could also use a change handler or a callback to update this variable too,
when transform $testObj changes do ID:#testHandler
(
testObject.pos.controller.'test attribs'.testval = testObject.pos
)
Perfect! Thanks guys.
I think I’ll do a hybrid of the two. A callback when the script interface is open and then shut it down when the interface is closed.
I’ve got a nifty new script I’ll be posting a prototype of probably by lunch.
Small modification to your code:
[left]when transform $testObj changes ID:#testHandlerID do (...)[/left]
[left]You had the ID after the do.[/left]
[left]Edit:[/left]
One small note… it doesn’t seem to update on every change of the transform but only the first transform. I guess it sort of lags one change behind.