View Single Post
03/04/17, 05:07 AM   #1
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
Manual submenu creation with LAMCreateControl

Having a bit of trouble getting this to work. From the LAM wiki:

CREATE CONTROL (advanced)

For manual control creation. You must handle anchoring of these controls, either to a LAM panel or a control of your choosing.

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.
  Reply With Quote