Thread Tools Display Modes
04/05/14, 12:28 PM   #1
Wukar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 27
So, the CreateControl doesn't seem to create a visual UI element, or should it?

When is either or used? Couldn't find a list of valid virtual names.
Code:
     CreateControl(string arg1, object parent, integer type)
        Returns: object apRet 

    CreateControlFromVirtual(string controlName, object parent, string virtualName)
        Returns: object apRet
Sigh, just the API is not too helpful ;-)
  Reply With Quote
04/05/14, 01:55 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
1. Unless you need to access this function from another file, make it local.
Lua Code:
  1. local function BBS_Initialize()

2. Only put your function name in the event handler. You want a reference for what to call when the event fires. Not what the function actually returns (which is, in this case, nil).

3. You need to tell the EVENT_MANAGER what is registering for this event. So the first argument is going to be a unique string for your addon. (The alternative is to register the event directly on a frame/control in your addon and skipping the event manager completely.)

4. EVENT_ADD_ON_LOADED fires for every addon that loads. You want to run your code if it's only your addon. Not 10 times for each addon that loads. Use either of the below.
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent(EVENT_ADD_ON_LOADED, function(event, addon
  2.      if addon == "MyAddonName" then
  3.           BBS_Initialize()
  4.      end
  5. end)
[highlight="Lua"]local function BBS_Initialize(event, addon)
if addon == "MyAddonName" then[
--do all the things
end
end/highlight]

4. You created an edit box, but you did not give it a height or say how it should look or anything else. As I mentioned above, I used a template so I didn't have to create it from scratch.


/edit: re-read these two parts of the Addon Quick Questions section of the wiki:
http://wiki.esoui.com/AddOn_Quick_Qu...events_work.3F
http://wiki.esoui.com/AddOn_Quick_Qu...s_or_labels.3F
  Reply With Quote
04/05/14, 02:15 PM   #3
Wukar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 27
Thanks for your effort in helping me

Nice hint with the ADD_ON_LOADED_EVENT. Thought it was possible but not sure of it.

Yeah, suddenly noticed copying the following was not a good idea
lua Code:
  1. editbox:SetResizeToFitDescendents(true)

I played around with zgoo a bit and tried to analyse the guild filter search box. The controls are structured CT_BACKDROP > CT_EDITBOX > CT_LABEL. I now wonder why the CT_LABEL is used as a child of CT_EDITBOX. Is it just because of a default text if the editbox value is (empty) - would make sense
  Reply With Quote
04/05/14, 03:33 PM   #4
Wukar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 27
Now i am stuck with setting appropriate handlers. Is there a list of valid and fireing events for controls? OnKeyup as well as Onclicked or OnFocus is not working.

lua Code:
  1. local function BBS_OnFocusLost(editbox, label)
  2.     label:SetHidden(editbox:GetText() ~= "")
  3. end
  4.  
  5. local function BBS_OnKeyUp(editbox, label)
  6.     label:SetHidden(editbox:GetText():len() > 0)
  7. end
  8.  
  9. editbox:SetHandler("OnKeyUp", function(self) BBS_OnKeyUp(self, label) end)
  10. editbox:SetHandler("OnFocusLost", function(self) BBS_OnFocusLost(self, label) end)
  Reply With Quote
04/05/14, 09:52 PM   #5
Lyrael
Join Date: Apr 2014
Posts: 2
Not sure how to add a filter as I found this trying to figure that out myself.

There is however an existing search box in the game, there's just no non-script way of showing it (AFAIK).

/script ZO_PlayerInventorySearchBox:ToggleHidden() will toggle its visibility.
  Reply With Quote
04/05/14, 10:35 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Yeah, I came across stuff referencing that last night but didn't look too much into it. Nice find.
  Reply With Quote
04/06/14, 04:07 AM   #7
Cr4x
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 11
Originally Posted by Wukar View Post
Now i am stuck with setting appropriate handlers. Is there a list of valid and fireing events for controls? OnKeyup as well as Onclicked or OnFocus is not working.

lua Code:
  1. local function BBS_OnFocusLost(editbox, label)
  2.     label:SetHidden(editbox:GetText() ~= "")
  3. end
  4.  
  5. local function BBS_OnKeyUp(editbox, label)
  6.     label:SetHidden(editbox:GetText():len() > 0)
  7. end
  8.  
  9. editbox:SetHandler("OnKeyUp", function(self) BBS_OnKeyUp(self, label) end)
  10. editbox:SetHandler("OnFocusLost", function(self) BBS_OnFocusLost(self, label) end)
wiki.esoui.com/UI_XML

Use zgoo to inspect which type of control you want to handle, head to the specific section and looks what it has of attributes additional childs and ofc which events (OnEvent). The most Controls inherits from Control which also have OnEvents so this is the overview you requested.

Originally Posted by Lyrael View Post
Not sure how to add a filter as I found this trying to figure that out myself.

There is however an existing search box in the game, there's just no non-script way of showing it (AFAIK).

/script ZO_PlayerInventorySearchBox:ToggleHidden() will toggle its visibility.
The search bar is working but, as you said, not there . I already figured that out too and was wondering why ZO isnt showing it . However if you want to add a filter, you may check the ZO_InventoryManager even the data sets of the different filters
  Reply With Quote
04/06/14, 06:56 AM   #8
Wukar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 27
Thanks for the event list, really helped out. Only thing i miss now, is how to capture events for closing/opening bank/inventory/guildbank.

I came across that InventorySearchBox, too, but was thinking it is for internal use only.

After showing it with :SetHidden(false), i first tried to reposition it with :SetParent(ZO_SharedRightPanelBackgroundLeft). But, strangely, changing its size with :SetDimensions(x, y) has no effect. :SetResizeToFitDescendents(false) has no effect, too.

God, why do easy considerations last that long to implement? Horrible, like looking for a needle in a haystack.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Adding elements to existing UI elements


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