Remove/destroy controls?
Is there any way to remove/destroy created controls in a save way?
After a animation i dont need them anymore and i do not want to spam the ui with hundreds of useless controls. |
No, there is no way to remove any control, so if you don't need one you just hide it and remove anchors. If you need to show it again, don't create another, but re-use the one you've made before. Controls clear when you /reloadui, or restart client.
|
Hmm, thanks Fyrakin.
|
Best way to handle a situation where you create a predictable amount of controls that you don't need all the time is using a ZO_ObjectPool.
You specify a Factory function that returns the object that is used and a Reset function that is called whenever an object is released. Lua Code:
When you need a new object you call AquireObject like this: Lua Code:
And once you are finished you can release it via the key: Lua Code:
If you don't care about specific objects you can also just call ReleaseAllObjects and reset them all at once: Lua Code:
EDIT: The comment in the zo_objectpool.lua is also quite interesting: Quote:
|
The templated control case is further simplified by ZO_ControlPool subclass, see e.g. http://esodata.uesp.net/100011/src/i....lua.html#1000
|
Thanks all, that will help.
|
I tried to recreate the example from sirinsidiator but can't get the label to show up ingame
following adjustments have been made: in EntryFactory: - local container = GuiRoot:CreateControl(name, CT_CONTROL) - labelA:SetText("this is the label") after creating new object: - entry:SetHidden(false) entry:SetAnchor(CENTER, parentControl, CENTER,0, 0 ) could some one point me into a direction? |
This example requires a bit of background knowledge. If you are new to addon development, you should try to look up some of the tutorials on the wiki instead. The SimpleNotebook Tutorial uses control pools in part 7.
|
I wouldn't call me "new" to addon development:
I have created several own addons (for example: cooldown tracker, combatlog related stuf, etc...) now I wanted to go the next step and create stuff dynamically... - I could't get either your example nor the example from the tutorial (yes I looked this up before posting here orginally!!) to work edit: managed to solve it by myself ;) |
All times are GMT -6. The time now is 01:14 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI