sirinsidiator / ESO-LibAddonMenu

http://www.esoui.com/downloads/info7-LibAddonMenu.html
Artistic License 2.0
41 stars 20 forks source link

LAM 2.0 r22: Nested menu's controls disabled state is not working if you got 3 levels of nesting #61

Closed Baertram closed 7 years ago

Baertram commented 7 years ago

If you build several levels of nested submenus like this: submenu1 { checkbox1 submenu2 { submenu3 { iconpicker colorpicker } } }

The iconpicker and colorpicker controls will be disabled if the checkbox control is checked. But the disabled state of the controls in the nested submenus does not change. It doesn't even change if the iconpicker or colorpicker controls would be in the submenu2.

sirinsidiator commented 7 years ago

Can you please make a small test addon with all the necessary menu elements? That would save me a lot of time.

Baertram commented 7 years ago

Hi there,

not able to find time for a small stand-alone test addon but you can use the current beta version of FCOItemSaver: https://dl.dropboxusercontent.com/u/34844455/ESO%20Addons/FCOItemSaver_0_8_7_beta.zip

Inside function BuildAddonMenu there are the submenus for the dynamic icons (line 11829): `--============================================================================== -- DYNAMIC ICONs --============================================================================== { type = "submenu", name = FCOIS.localizationVars.fcois_loc["options_icons_dynamic"], controls = { ... --New submenu in the dynamic icons submenu here. For each icon 1 submenu

} -- controls }--submenu dynamic icons`

They are located inside the submenu for all the icons of the addon, starting at line 10490: ` --==============================================================================

-- vvv OTHER ICONS vvv

    {
        type = "submenu",
        name = FCOIS.localizationVars.fcois_loc["options_header_color"],
        controls = {

...`

Outside of the submenus there are located some checkboxes to disable/enable the icon and all related controls. If you use the checkboxes of the icons (normal, gear sets, dynamic icons) to enable/disable them the related controls in the icon's submenu won't update the disabled state.

e.g. disable the "dynamic icon 1" checkbox -> the name editbox, colorpicker and iconpicker for the dynamic icon 1, located in the submenu "dynamic icons" and there inside the next submenu "dyanmic icon 1", won't update the disabled state.

Baertram commented 7 years ago

I think I found out where the problem is. After some debugging with debug text messages I saw that the function "requestRefreshIfNeeded" is not getting the toppanel of the control. It always looked at the panel of the control from the parameter which was a submenu if the control initiating the update was a control in a submenu, in another submenu.

This fixed the issue but i'm not sure if it will raise other problems?

local function RequestRefreshIfNeeded(control)

-- if our parent window wants to refresh controls, then add this to the list
   local panel = GetTopPanel(control.panel)
    local panelData = panel.data
    if panelData.registerForRefresh then
        cm:FireCallbacks("LAM-RefreshPanel", control)
    end
end