Thread Tools Display Modes
04/28/14, 05:26 AM   #1
LoPony
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 10
SetHidden and event handlers

Hello!

I’m a little bit confused.
If I hide a TopLevelControl with control:SetHidden( true ), my OnUpdate-Handler stops working.

Example:
Code:
control:SetHandler( 'OnUpdate', function() OnUpdate() end )
It starts again after using control:SetHidden( false )

Does all events defined by control:SetHandler or control:RegisterForEvent stop working if the control is hidden?
Haven’t tested all the possible events and also not tested events defined by the EVENT_MANAGER.

Is this working as intended?
Is there any possibility to run OnUpdate even if the control isn’t visible (but should still update some data)?

greetings
  Reply With Quote
04/28/14, 05:40 AM   #2
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
Event handlers registered with control:RegisterForEvent will trigger regardless the control hidden status, but handler registered with control:SetHandler will not. Take "OnMoseEnter" for example - since the control is hidden how can it receive this event?

You can use EVENT_MANAGER:RegisterForUpdate(some_name, time, your_function). This function is not documented on the wiki page. It will call your_function at "time" intervals. time is in miliseconds and can be 0 to kill your framerate . Then you can call EVENT_MANAGER:UnregisterForUpdate(some_name) to unregister your handler function.

Last edited by Harven : 04/28/14 at 05:52 AM.
  Reply With Quote
04/28/14, 07:55 AM   #3
LoPony
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 10
If RegisterForUpdate works, I wont need any OnUpdate handler at all.
I'll give it a try asap, thanks Harven
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » SetHidden and event handlers


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off