Thread Tools Display Modes
05/16/14, 03:33 AM   #1
CrazyDutchGuy
 
CrazyDutchGuy's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 89
Add items to menubar and handling selection

Bit weird of a topic cause i didn't know how to word it in short.

Anyways. The following problem. We all know the menubars ingame. For example the one above the screen with skills, character, mail, and so forth. But also the one to the right when you open your map, where you can select quests, zones, icons, and so on.

I added a menubar button item to the right pane when you are in map mode. The button itself works correctly. Meaning it highlight when selected and unhighlights when another button in the menubar is selected.

What i expected when adding the button is that when you select quests, you get also the quest overview. When you select zones, you get the zone overview. When you select my button, you get nothing (cause i did not define anything). However it stays on the last selection.

The button when defined has a callbackhandler, but that only fires when selected. The buttons should behave in a way similar to a radiogroup control.

What i couldn't find and looking for is : How does the right pane handle the button state changes, so that it results in new information below the menubar ? Or how in general is button state changes handled from a menubar perspective ?
  Reply With Quote
05/16/14, 12:20 PM   #2
CrazyDutchGuy
 
CrazyDutchGuy's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 89
Ok, a small snippet on how the button is created and added to the right pane. Now, can anyone tell me how do i hide/show data based on enabled/disabled state of that button ? It's driving me nuts ....

Code:
local buttonData = 
{ 
	descriptor = "RightPaneButton",
  	normal = "EsoUI/Art/mainmenu/menubar_journal_up.dds",
        pressed = "EsoUI/Art/mainmenu/menubar_journal_down.dds",
        disabled = "EsoUI/Art/mainmenu/menubar_journal_disabled.dds",
        highlight = "EsoUI/Art/mainmenu/menubar_journal_over.dds",
        callback =  function(...) d("callbackdata") end,
}

local menubar = WINDOW_MANAGER:GetControlByName("ZO_WorldMapInfoMenuBar")
local button = ZO_MenuBar_AddButton(WINDOW_MANAGER:GetControlByName("ZO_WorldMapInfoMenuBar"), buttonData)

Last edited by CrazyDutchGuy : 05/16/14 at 12:22 PM. Reason: layout code
  Reply With Quote
05/16/14, 06:09 PM   #3
katkat42
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 155
It's possible the mechanism is similar to the one for showing/hiding buttons on the keybind strip. See: http://wiki.esoui.com/How_to_add_but...able.2FDisable

ETA: You'd have to find the WorldMapInfoMenuBar equivalent to KEYBIND_STRIP:UpdateKeybindButtonGroup(myButtonGroup) though.
  Reply With Quote
05/16/14, 10:25 PM   #4
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
ZO_WorldMapInfoMenuBar is not just menu bar, but scene fragment bar (menu bar with added functionality).

To add button you need to use function:
Lua Code:
  1. ZO_WorldMapInfoMenuBar:Add(name, fragmentGroup, buttonData, keybindButton)

So, if I update your code:
Lua Code:
  1. local buttonData = {
  2.    normal = "EsoUI/Art/mainmenu/menubar_journal_up.dds",
  3.    pressed = "EsoUI/Art/mainmenu/menubar_journal_down.dds",
  4.    highlight = "EsoUI/Art/mainmenu/menubar_journal_over.dds",
  5.    callback =  function(...) d("callbackdata") end,
  6. }
  7.  
  8. local bossFragment = ZO_FadeSceneFragment:New(control) --control is your stuff you want to show/hide
  9.  
  10. ZO_WorldMapInfoMenuBar:Add("Boss Drops", {bossFragment}, buttonData)
  Reply With Quote
05/17/14, 04:33 AM   #5
CrazyDutchGuy
 
CrazyDutchGuy's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 89
When i call ZO_WorldMapInfoMenuBar:Add(name, fragmentGroup, buttonData, keybindButton) then i get an error "function expected instead of nil.

So apparantly the ZO_WorldMapInfoMenuBar:Add is either not public or using the wrong control object to add. The MenuBarTemplate which ZO_WorldMapInfoMenuBar derives from doesn't define an :Add, so I asumming the wrong object to add.

In more detail what i can find
ZO_WorldMapInfoMenuBar is a virtual control that derives from ZO_MenuBarTemplate, which does not define :Add
ZO_WorldMapInfo defines a control ZO_WorldMapInfoMenuBar that derives from the virtual ZO_WorldMapInfoMenuBar , which does define the :Add

I am assuming the double naming is messing the stuff up, and allways returns the virtual control object

Last edited by CrazyDutchGuy : 05/17/14 at 05:00 AM.
  Reply With Quote
05/17/14, 05:42 AM   #6
Aicam
Join Date: Apr 2014
Posts: 16
if that is the case this should do the job of retreiving the right contol:
Lua Code:
  1. ZO_WorldMapInfo:GetNamedChild("MenuBar"):Add( ... )
  Reply With Quote
05/17/14, 06:06 AM   #7
CrazyDutchGuy
 
CrazyDutchGuy's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 89
Originally Posted by Aicam View Post
if that is the case this should do the job of retreiving the right contol:
Lua Code:
  1. ZO_WorldMapInfo:GetNamedChild("MenuBar"):Add( ... )
That is something i tried as well. Still if i do it like that, it still says "function expected instead of nil". So I am confused. I am not sure if it is even possible to add it to the ZO_WorldMapInfoMenuBar in the way i want it to happen.
  Reply With Quote
05/17/14, 08:02 AM   #8
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by CrazyDutchGuy View Post
When i call ZO_WorldMapInfoMenuBar:Add(name, fragmentGroup, buttonData, keybindButton) then i get an error "function expected instead of nil.

So apparantly the ZO_WorldMapInfoMenuBar:Add is either not public or using the wrong control object to add. The MenuBarTemplate which ZO_WorldMapInfoMenuBar derives from doesn't define an :Add, so I asumming the wrong object to add.

In more detail what i can find
ZO_WorldMapInfoMenuBar is a virtual control that derives from ZO_MenuBarTemplate, which does not define :Add
ZO_WorldMapInfo defines a control ZO_WorldMapInfoMenuBar that derives from the virtual ZO_WorldMapInfoMenuBar , which does define the :Add

I am assuming the double naming is messing the stuff up, and allways returns the virtual control object
By bad, I didn't test it first. Instead of ZO_WorldMapInfoMenuBar use WORLD_MAP_INFO.menuBar.

Code that I have tested, so it works:
Lua Code:
  1. local tlw, texture
  2. tlw = WINDOW_MANAGER:CreateTopLevelWindow()
  3. tlw:SetDimensions(128,128)
  4. tlw:SetAnchor(TOP, ZO_WorldMapInfo, TOP, 0, 100)
  5. tlw:SetHidden(true)
  6. texture = WINDOW_MANAGER:CreateControl(nil, tlw, CT_TEXTURE)
  7. texture:SetTexture("/esoui/art/icons/poi/poi_groupboss_complete.dds")
  8. texture:SetAnchorFill(tlw)
  9.  
  10. ZO_CreateStringId("BOSS_DROPS_NAME", "Boss drops")
  11.  
  12. local bossFragment = ZO_FadeSceneFragment:New(tlw)
  13.  
  14. local buttonData = {
  15.    normal = "EsoUI/Art/mainmenu/menubar_journal_up.dds",
  16.    pressed = "EsoUI/Art/mainmenu/menubar_journal_down.dds",
  17.    highlight = "EsoUI/Art/mainmenu/menubar_journal_over.dds",
  18.    callback =  function(...) d("callbackdata") end,
  19. }
  20.  
  21. WORLD_MAP_INFO.modeBar:Add(BOSS_DROPS_NAME, {bossFragment}, buttonData)
  Reply With Quote
05/17/14, 08:23 AM   #9
Aicam
Join Date: Apr 2014
Posts: 16
Lua Code:
  1. WORLD_MAP_INFO.modeBar:Add( ... )
Apparently the first argument is a string id and not a string. So you need to create your string with
ZO_CreateStringId( name, string ), which is inserted into the global namespace.
And from what i saw the callback is only needed if you want to do things other than showing your fragment,
the 4 other buttons don't have a callback in their buttonData.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Add items to menubar and handling selection


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