Thread Tools Display Modes
03/16/15, 05:14 PM   #1
Weolo
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 79
ZO_MenuBarTemplate

I want to have a series of buttons which act like radio buttons, only one can be chosen at a time. I fould information on ZO_MenuBarTemplate and it seemed perfect but when I try to use it I get an error.

This is how I set it up.
XML
Lua Code:
  1. <GuiXml>
  2.     <Controls>
  3.         <Control name="testBar1" inherits="ZO_MenuBarTemplate" virtual="true">
  4.         </Control>
  5.     </Controls>
  6. </GuiXml>

LUA
Lua Code:
  1. local menuBar = CreateControlFromVirtual("testBar1", GuiRoot, "ZO_MenuBarTemplate")
  2. menuBar:SetAnchor(TOPRIGHT, GuiRoot, TOPRIGHT, 0, 0)
  3. local data = {
  4.     descriptor = "fancy",
  5.     normal = "EsoUI/Art/Inventory/inventory_tabIcon_weapons_up.dds",
  6.     pressed = "EsoUI/Art/Inventory/inventory_tabIcon_weapons_down.dds",
  7.     disabled = "EsoUI/Art/Inventory/inventory_tabIcon_weapons_disabled.dds",
  8.     highlight = "EsoUI/Art/Inventory/inventory_tabIcon_weapons_over.dds",
  9.     callback = function(tabData) d("Menu button clicked") end,
  10. }
  11. local newControl = ZO_MenuBar_AddButton(menuBar, data)

Error
Code:
EsoUI/Libraries/ZO_MenuBar/ZO_MenuBar/lua:383: attempt to index a nil value
stack traceback:
EsoUI/Libraries/ZO_MennuBar/ZO_MenuBar.lua:383: in function 'MenuBar:AddButton'
(tail call): ?
Then the lines of code from my addon which started this off, which is the "ZO_MenuBar_AddButton(menuBar, data)" line 11 in my example above.

I am doing something wrong, can anyone spot what it is?
  Reply With Quote
03/16/15, 06:05 PM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
You have to call ZO_MenuBar_SetData(menuBar, barData) before you add buttons. SetData will create control pool which you need for buttons.

Template "ZO_DefaultMenuBar" has this call already in OnInitialized handler, so you can just change template from "ZO_MenuBarTemplate" to "ZO_DefaultMenuBar".

If you want to set data manually, add to your code something like this:
Lua Code:
  1. local barData = {
  2.     buttonPadding = 20,
  3.     normalSize = 51,
  4.     downSize = 64,
  5.     animationDuration = DEFAULT_SCENE_TRANSITION_TIME,
  6.     buttonTemplate = "ZO_MenuBarButtonTemplate1",
  7. }
  8. ZO_MenuBar_SetData(menuBar, barData)
  Reply With Quote
03/16/15, 10:41 PM   #3
Weolo
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 79
Brilliant!
Great answer as always Garkin, I will add that in to my code right now and give it a whirl.

Ahh no better wait for ESO to patch in to Tamriel Unlimited

Thanks for the help
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » ZO_MenuBarTemplate


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