ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   How to destroy control elements (https://www.esoui.com/forums/showthread.php?t=1481)

CrazyDutchGuy 05/12/14 01:37 PM

How to destroy control elements
 
I have a bunch of unnamed control windows in my TopLevelControl. Depending on the situation the controls are different, but the TopLevelControl and it's background remain the same. How can i destroy these control elements nicely ?

ingeniousclown 05/12/14 01:43 PM

Quote:

Originally Posted by CrazyDutchGuy (Post 7601)
I have a bunch of unnamed control windows in my TopLevelControl. Depending on the situation the controls are different, but the TopLevelControl and it's background remain the same. How can i destroy these control elements nicely ?

First off, how did you end up with unnamed controls? I wasn't aware that this is even possible.

Second, you can not destroy controls. Once they're created, they exist until you reloadui. You should aim to re-use controls as much as you feasibly can.

CrazyDutchGuy 05/12/14 01:49 PM

It is not required to name controls.

I could reuse the controls, but the code would be unnecessary complex. They kinda are all labels, but indentation may differ, they have different event handlers and so on.

it would be more easier to destroy and recreate. But if it is not possible, then i am forced to reuse :)

Roupine 05/12/14 02:04 PM

I could be wrong but there is no way to delete controls once they've been created, short of reloading the UI.
The best way to work with "temporary" controls is to use ZO_ObjectPool

ingeniousclown 05/12/14 02:11 PM

Quote:

Originally Posted by CrazyDutchGuy (Post 7604)
It is not required to name controls.

The name is the very first argument in CreateControl (second if you count the WINDOW_MANAGER self). Is there some other method for creating controls that I am not aware of?

I'm not sure what your context is, but you could do kind of what the options menu does. The options window is home to a number of option panels, access to which changes depending on which options menu you went to open. It would require a bit of engineering, but based on you description that seems like a possible solution for you.

CrazyDutchGuy 05/12/14 02:46 PM

You can just give a nil value for the name. I am not sure it is bad behavior to do so. But if you never going to reference the control by name, why name it then, and pollute the namespace.

Kith 05/12/14 04:21 PM

Quote:

Originally Posted by CrazyDutchGuy (Post 7610)
You can just give a nil value for the name. I am not sure it is bad behavior to do so. But if you never going to reference the control by name, why name it then, and pollute the namespace.

Unless ESO is doing something weird, its not bad behavior to leave the window with a nil name. As you say, it is one less entry in the global namespace and you can still reference those via internally saved variables. There may be some ZO_TEMPLATES that don't function properly without a name though (as some use something along the lines of GetControl(namehere) to access internal components.

Other than my options menus (using LAM), I never name any controls other than the 'base' that serves as my mods main addon table.

Seerah 05/12/14 04:39 PM

Yes, there are some ZO templates that require a frame name in order to function properly. This is if they use $(parent) when naming children and/or when utilizing other functions that reference the frame name, as mentioned.

However, if you are creating the controls yourself, you can just use nil in place of a global frame name/reference.


All times are GMT -6. The time now is 07:59 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI