View Single Post
02/05/15, 09:36 AM   #19
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
After update to r16 because of Update 5, LAM doesn't properly select nodes in game menu tree when you open settings menu from slash command. Here is my (unfinished) solution:

Lua Code:
  1. --METHOD: OPEN TO ADDON PANEL--
  2. --opens to a specific addon's option panel
  3. --Usage:
  4. --  panel = userdata; the panel returned by the :RegisterOptionsPanel method
  5. local locSettings = GetString(SI_GAME_MENU_SETTINGS)
  6. function lam:OpenToPanel(panel)
  7.     SCENE_MANAGER:Show("gameMenuInGame")
  8.     zo_callLater(function()
  9.             local settingsMenu = ZO_GameMenu_InGame.gameMenu.headerControls[locSettings]
  10.             settingsMenu:SetOpen(true)
  11.             SCENE_MANAGER:AddFragment(OPTIONS_WINDOW_FRAGMENT)
  12.             KEYBOARD_OPTIONS:ChangePanels(lam.panelID)
  13.             for i, child in pairs(settingsMenu.children) do
  14.                 if type(child) == "table" and child.data.name == KEYBOARD_OPTIONS.panelNames[lam.panelID] then
  15.                     ZO_TreeEntry_OnMouseUp(child.control, true)
  16.                     break
  17.                 end
  18.             end
  19.             panel:SetHidden(false)
  20.         end, 200)
  21. end

It is not finished yet, because there is still one issue - it doesn't properly select button in addon list and scroll list does not move to that button. If I want to fix that, I will have to get reference for addon button. Probably the best would be adding it to panel itself. I have to try what I can do without extensive changes to the code.

EDIT:
Button is selected, but scroll list scrolls to the button only if button list is already initialized, when you open LAM settings for the first time it doesn't work.
Lua Code:
  1. --METHOD: OPEN TO ADDON PANEL--
  2. --opens to a specific addon's option panel
  3. --Usage:
  4. --  panel = userdata; the panel returned by the :RegisterOptionsPanel method
  5. local locSettings = GetString(SI_GAME_MENU_SETTINGS)
  6. function lam:OpenToPanel(panel)
  7.     SCENE_MANAGER:Show("gameMenuInGame")
  8.     zo_callLater(function()
  9.             local settingsMenu = ZO_GameMenu_InGame.gameMenu.headerControls[locSettings]
  10.             settingsMenu:SetOpen(true)
  11.             SCENE_MANAGER:AddFragment(OPTIONS_WINDOW_FRAGMENT)
  12.             KEYBOARD_OPTIONS:ChangePanels(lam.panelID)
  13.             for i, child in pairs(settingsMenu.children) do
  14.                 if type(child) == "table" and child.data.name == KEYBOARD_OPTIONS.panelNames[lam.panelID] then
  15.                     ZO_TreeEntry_OnMouseUp(child.control, true)
  16.                     break
  17.                 end
  18.             end
  19.             local scroll = LAMAddonPanelsMenuScrollChild
  20.             for i = 1, scroll:GetNumChildren() do
  21.                 local button = scroll:GetChild(i)
  22.                 if button.panel == panel then
  23.                     zo_callHandler(button, "OnClicked")
  24.                     ZO_Scroll_ScrollControlToTop(LAMAddonPanelsMenu, button)
  25.                     break
  26.                 end
  27.             end
  28.         end, 200)
  29. end

Last edited by Garkin : 02/05/15 at 10:16 AM.
  Reply With Quote