MAXScript FAQ > Scripted UI > How do I uncheck a MacroScript button correctly? |
Let's say you have a macroscript button that opens a dialog. Now you'd like to take advantage of the isChecked handler to show the button being checked when the dialog is open and when pressed again (unchecked) will close the dialog. So far so good. Now the user closes the interface using the [x] button.. or any other means except pressing that same macroscript button. How does one go about un-checking that macroscript button?
Here is one possible way to implement this behavior using a "private global" variable (local to the macro Script's scope) which holds the current open/closed state.
This variable can be set from inside the On Close() handler of the rollout so when you hit[X], it forces the3ds MaxGUI to update and uncheck the button.
This can be done using a global variable (if you want other scripts to be able to force your script / dialog to close).Also, more error checking could be added, but the general idea is this: