PDA

View Full Version : setVisible question



meathome
November 25th, 2008, 03:37
How can i make my control remember its setVisible state? I call setVisible in onInit() depending on some other controls. When i create a new char it works, but when i close the charsheet and reopen it the cotrols that previously where invisible are visible again.

Brenn
November 25th, 2008, 04:39
You can use either the Campaign Registry (much in the same way the windows last positions are stored) or the database.

I don't know exactly what you are trying to do exactly, but it would seem to me that this could be done in script with the right logic, unless the user of the sheet is controlling the visibility of the controls independently, in which case I would go down the path I said above.

If you don't want to maintain the conditions between sessions, you could just set up a global table in a base script that isn't tied to a window (such as ChatManager or one you create) and store the states in that table.

There are quite a few ways the more I think about it. With the Registry and the database being the truly persistent ones.

Sorry about the rambling, I'm tired and so just really subjecting you to more of a stream of consciousness than anything else.

I'll go to bed now. ;)

Foen
November 25th, 2008, 06:29
The onInit event fires whenever the control is rendered, so it will occur when you reopen a window not just when it is first created. If your code only works when a window is first created, then there is probably some other problem.

Try using print() to write the values of the dependent controls to the console, and see what differences you get between new instances and reopened instances.

Foen

meathome
November 25th, 2008, 08:28
Thanks! Managed to solve it. Sorry for all the questions btw... it seems most of my problems are caused by me being used to a comfortable debugger ala visual studio. Debugging lua is quite a bit harder.