ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   destroying Controls (https://www.esoui.com/forums/showthread.php?t=9756)

siruker 05/31/21 03:49 AM

destroying Controls
 
you can create control with

Code:

CreateControl("ControlName", CT_LABEL )
how would one go about destroying it.
I have seen examples that merely hide the control but I want to destroy it completely.
Currently I have an issue where making too many controls will start screwing with fps. So the controls are not getting removed.

Baertram 05/31/21 05:20 AM

Controls are not destroyed even if you set them = nil. The garbage collector of lua will keep them until next reloadui afaik
You need to reuse controls via control pools, instead of creating new ones, if possible.
Else only create controls that you really need as you need them.

siruker 05/31/21 06:37 AM

Quote:

Originally Posted by Baertram (Post 43995)
Controls are not destroyed even if you set them = nil. The garbage collector of lua will keep them until next reloadui afaik
You need to reuse controls via control pools, instead of creating new ones, if possible.
Else only create controls that you really need as you need them.

Okay I was afraid of that. If anybody knows a way for destroying them let me know. Maybe people are lazy as in normal usecases you would never create that many for it to become issue and the way to destroy them isn't known. when I was searching I came across this https://esoapi.uesp.net/100030/data/c/l/e/ClearCustomControl.html

but I have no idea how I would go around using it.

EDIT:

nvm took a look https://esoapi.uesp.net/100030/src/l...g.lua.html#151 it just hides it.

Baertram 05/31/21 07:05 AM

I'd just create controls and reuse them instead of creating new ones. That's what ZO_ObjectPool could do e.g. Or maybe there is ZO_ControlPool as well, or similar.

ZOS_DanBatson 06/01/21 06:54 PM

There is, in fact, a ZO_ControlPool class :p

And no, once created, controls cannot be destroyed (they will only be destroyed on a reloadui). So you should not make infinite controls. ZO_ControlPool is a wise move if you need to continually add/remove/recycle a variable number of controls.

andy.s 06/02/21 01:24 AM

I think it's also worth mentioning that reusing already created controls is much faster than deleting them (if it were possible) and creating again.

ShadowMau 06/03/21 08:25 AM

If you look at Simple Tooltip I use object pools to make and recycle tooltip controls. I don't claim to be an expert, but it does work and I have used GetTotalObjectCount() to make sure the pool is not running away (I left the object checks commented out in the code). If you look at the documentation in Simple Tooltip, I think I give you enough to get an easy start.

I did not know about control pools so I might look into those.


All times are GMT -6. The time now is 10:25 PM.

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