03/04/17, 05:07 AM | #1 | |
Manual submenu creation with LAMCreateControl
Having a bit of trouble getting this to work. From the LAM wiki:
So, here is what I tried: Code:
for entry, widgetData in ipairs(panelData) do local widgetType = widgetData.type local widget = LAMCreateControl[widgetType](panel, widgetData) if widgetData.controls ~= nil then local lastSubWidget = widget for subEntry, subWidgetData in ipairs(widgetData.controls) do local subWidgetType = subWidgetData.type d(subWidgetType) local subWidget = LAMCreateControl[subWidgetType](panel, subWidgetData) subWidget:SetAnchor(TOPLEFT, lastSubWidget, TOPLEFT, 0, 0) lastSubWidget = subWidget end end Visiting the panel in question I do get a list of debug printouts for the correct widget types from the submenu's controls. The submenu itself is created, there are no LUA errors, however it will not expand and all the widgets appear to get scrunched together on top of instead of within the submenu widget: I also tried local lastSubWidget = GetControl(widgetData.reference) and adding reference = "UniqueSubmenuName", to the submenu in question, with the exact same results (should reference same control as 'widget' in this context). Seems to be I am just anchoring these sub-widgets wrongly, but how to do so correctly? NOTE: Why even have the sub-loop? Because, if I just leave the "if widgetData.controls ~= nil then" block out completely, LAM does not create the widgets for the submenu contained within widgetData.control. Could it be a possible LAM bug with submenu widgets called from LAMCreateControl? I think it is more like I just need to change some subtle syntax. O.o Last edited by Phinix : 03/04/17 at 05:58 AM. |
||
03/04/17, 07:39 AM | #2 |
I am working on just hooking widget.label:SetHandler("OnMouseUp" and manually re-sizing and re-populating the panel, and hiding/showing the sub-menu widgets accordingly using table lookups. Seems like it could work at least.
|
|
03/04/17, 01:52 PM | #3 |
Managed to work around this issue with a custom framework. Might be a better way though. Still this is relatively clean and painless and allows copy-paste adding of submenus without additional code. The only minor hassle is getting the height value for the expanded menu.
Code:
local subWidgets = { -- the names here are from the reference = "" field on the submenu widget ["SrendarrBlacklistSubmenu"] = {height = 162, widgets = {}}, ["SrendarrAuraWhitelistSubmenu"] = {height = 381, widgets = {}}, ["SrendarrDebuffWhitelistSubmenu"] = {height = 237, widgets = {}}, ["SrendarrGroupWhitelistSubmenu"] = {height = 278, widgets = {}}, ["SrendarrPlayerFilterSubmenu"] = {height = 318, widgets = {}}, ["SrendarrTargetFilterSubmenu"] = {height = 441, widgets = {}}, ["SrendarrDisplayGroupSubmenu"] = {height = 532, widgets = {}}, ["SrendarrDebugSubmenu"] = {height = 278, widgets = {}}, } for entry, widgetData in ipairs(panelData) do local widgetType = widgetData.type local widget = LAMCreateControl[widgetType](panel, widgetData) local function ToggleSubmenu(clicked) -- toggle simulated sub-menus (Phinix) local control = clicked:GetParent() local subWidgetsDB = subWidgets[control.data.reference] if control.open then control.bg:SetDimensions(panel:GetWidth() + 19, 30) control.label:SetDimensions(panel:GetWidth(), 30) control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") for s = 1, #subWidgetsDB.widgets do local subWidget = subWidgetsDB.widgets[s].w subWidget:SetHidden(true) end control.open = false else control.bg:SetDimensions(panel:GetWidth() + 19, subWidgetsDB.height) control.label:SetDimensions(panel:GetWidth(), subWidgetsDB.height) control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortup.dds") for s = 1, #subWidgetsDB.widgets do local subWidget = subWidgetsDB.widgets[s].w subWidget:SetHidden(false) end control.open = true end end if widgetData.controls ~= nil then -- simulate sub-menu widgets for custom panels (Phinix) local lastSubWidget = widget.label local subWidgetsDB = subWidgets[widget.data.reference] widget.label:SetHandler("OnMouseUp", ToggleSubmenu) widget.scroll:SetDimensionConstraints(panel:GetWidth() + 19, 0, panel:GetWidth() + 19, 0) widget.label:SetDimensions(panel:GetWidth(), (widget.open) and subWidgetsDB.height or 30) widget.bg:SetDimensions(panel:GetWidth() + 19, (widget.open) and subWidgetsDB.height or 30) for subEntry, subWidgetData in ipairs(widgetData.controls) do local subWidgetType = subWidgetData.type local subWidget = LAMCreateControl[subWidgetType](panel, subWidgetData) subWidget:SetAnchor(TOPLEFT, lastSubWidget, (lastSubWidget == widget.label) and TOPLEFT or BOTTOMLEFT, 0, (lastSubWidget == widget.label) and 45 or 15) subWidgetsDB.widgets[subEntry] = {w = subWidget} ... other code goes here ... if not widget.open then subWidget:SetHidden(true) else subWidget:SetHidden(false) end lastSubWidget = subWidget end end end |
|
ESOUI » Developer Discussions » Lua/XML Help » Manual submenu creation with LAMCreateControl |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|