[Closed] destroy dialogs
Hi,
I’ve got some dialogs I would like to be destroyed when an open scene or reset is performed. As a test I tried:
fn clearSynoptics = (
try(destroyDialog myDialog )catch()
print "function called"
)
callbacks.addScript #filePostOpen "clearSynoptics()" id:#myFileOpenCallbackTest
and saved it as a startup script but it dosen’t work, when I open scene files the dialog remains. Strange thing is if I just evaluate this line:
try(destroyDialog myDialog )catch()
in the listener the dialog does get destroyed OK? How do I get this to work in a callback startup script?
Thanks for reading
You are defining clearSynoptics on startup. At this stage, I assume that myDialog does not yet exist and is not defined. Therefore it is evaluated as a function local variable of clearSynoptics. When later the function is called, it is not aware that myDialog is now also a global rollout variable. It keeps treating is a local variable (with a value of undefined). Use the scoping operator ( :: ) to explicitly refer to the global myDialog variable:
fn clearSynoptics = (
try(destroyDialog ::myDialog )catch()
print "function called"
)
callbacks.addScript #filePostOpen "clearSynoptics()" id:#myFileOpenCallbackTest
Also, why not define this callback only after the rollout is defined and created?
Many thanks that worked, and thanks for the explanation. Originaly I did try defining the callback within an on rollout open block of code. But it didn’t work I’ll assume it was because I had made an error though!
Thanks again
Dan