ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Dynamical LibAddonMenu (https://www.esoui.com/forums/showthread.php?t=9356)

Crunatus 08/24/20 12:02 PM

Dynamical LibAddonMenu
 
Hi all,

Whether it is possible to create menu dynamically, when opening the settings menu, with different number of elements?

Wheels 08/24/20 01:38 PM

Yes it's possible, you can create the menu elements in a loop and add them to the table of controls that you give to LAM for example

Crunatus 08/24/20 02:31 PM

I didn't put it that way, I didn't mean dynamic creation, but dynamic change every time you open Settings. Each time you open it, a new panel is created.

Baertram 08/24/20 03:57 PM

Check the LAM docu for the possible callback functions you could register, e.g.

Lua Code:
  1. local panelData = {
  2.         type                = 'panel',
  3.         name                = addonVars.addonNameMenu,
  4.         displayName         = addonVars.addonNameMenuDisplay,
  5.         author              = addonVars.addonAuthor,
  6.         version             = addonVars.addonVersionOptions,
  7.         registerForRefresh  = true,
  8.         registerForDefaults = true,
  9.         slashCommand        = "/myaddons",
  10.         website             = addonVars.website,
  11.         feedback            = addonVars.feedback,
  12.         donation            = addonVars.donation,
  13.     }
  14.     --The LibAddonMenu2.0 settings panel reference variable
  15.     myAddon.LAMPanel = LibAddonMenu2:RegisterAddonPanel(addonVars.gAddonName .. "_LAM", panelData)
  16.  
  17. local function MyLAMPanelCreated(panel)
  18.    --only if MY addon's LAM panel was created
  19.    if panel ~= myAddon.LAMPanel then return end
  20. end
  21.    
  22.    
  23.  
  24.     CALLBACK_MANAGER:RegisterCallback("LAM-PanelControlsCreated", MyLAMPanelCreated)
  25.     CALLBACK_MANAGER:RegisterCallback("LAM-RefreshPanel", MyLAMPanelRefreshed)
  26.     CALLBACK_MANAGER:RegisterCallback("LAM-PanelOpened", MyLAMPanelOpened)
  27.     CALLBACK_MANAGER:RegisterCallback("LAM-PanelClosed", MyLAMPanelClosed)

LAM-RefreshPanel will be called for each update of any of the controls in the panel!

Not sure if this is what you needed, else describe your usecase in detail/with an example please.

Crunatus 08/24/20 05:52 PM

Thank you, Baertram. LAM-RefreshPanel this is exactly what I was looking for.


All times are GMT -6. The time now is 10:21 PM.

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