ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Add items to menubar and handling selection (https://www.esoui.com/forums/showthread.php?t=1518)

CrazyDutchGuy 05/16/14 03:33 AM

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 ?

CrazyDutchGuy 05/16/14 12:20 PM

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)


katkat42 05/16/14 06:09 PM

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.

Garkin 05/16/14 10:25 PM

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)

CrazyDutchGuy 05/17/14 04:33 AM

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

Aicam 05/17/14 05:42 AM

if that is the case this should do the job of retreiving the right contol:
Lua Code:
  1. ZO_WorldMapInfo:GetNamedChild("MenuBar"):Add( ... )

CrazyDutchGuy 05/17/14 06:06 AM

Quote:

Originally Posted by Aicam (Post 7916)
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.

Garkin 05/17/14 08:02 AM

Quote:

Originally Posted by CrazyDutchGuy (Post 7912)
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)

Aicam 05/17/14 08:23 AM

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.


All times are GMT -6. The time now is 03:17 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI