Thread Tools Display Modes
11/24/15, 01:36 AM   #1
Weaselkit
Join Date: Nov 2015
Posts: 3
CreateControlFromVirtual parameters

Hello, I'm new to this and getting my feet wet with tutorials and the function lists.

I currently have a interface that is working as intended except when I call a function that dynamically creates drop down windows (combo boxes), I lose my custom background for the whole ... control? As long as I don't call the function, I keep my custom setup so I know the problem is with the function and I think it has to do with this "ZO_DefaultBackdrop" and SetAnchorFill(), I can''t quite figure out how these work or find an alternative to ZO_DefaultBackdrop so I could test my hypothesis.



Code:
local function loadDropDowns(name, tip, x, y, list) 

	local bd = WINDOW_MANAGER:CreateControlFromVirtual("comboBox"..name, tlw, "ZO_DefaultBackdrop")
		bd:SetAnchorFill()
	
	local comboBox = WINDOW_MANAGER:CreateControlFromVirtual("combo"..name, tlw, "ZO_ComboBox")
		comboBox:SetDimensions(150, 30)
		comboBox:ClearAnchors()
		comboBox:SetAnchor(TOPLEFT, tlw, TOPLEFT, x, y)
		
		-- tooltip text
		comboBox.data = { tooltipText = tip }
		
		-- tooltip handlers
		comboBox:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter)
		comboBox:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)
		
	local m_comboBox = comboBox.m_comboBox
		m_comboBox:SetSortsItems(true)
		
		-- easy access references from tlw
		--tlw.backdrop = bd
		--tlw.comboBox = comboBox
		--tlw.m_comboBox = m_comboBox
		
			m_comboBox:AddItems(list)

end
I snatched this function from http://www.esoui.com/forums/showthread.php?t=4697
  Reply With Quote
11/24/15, 02:11 AM   #2
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
If I understand you correctly. When you say you loose the background for the "whole control" I'm assuming you mean your tlw.

Since tlw is not defined in this function I'll assume its defined somewhere else in your file. Or if your copying that example I posted in that thread, did you forget to create the tlw?

By what you said though my guess is that you created some tlw control elsewhere that has a custom backdrop and then your trying to dynamically create dropdowns and place them on that tlw.

If so your problem would probably be because when you create the backdrop its parent is tlw & you use SetAnchorFill() which fills up the entire space of its parent, which is the tlw and probably not what you wanted because it would overlap your tlw's custom backdrop. The default backdrop is probably sitting on top of your custom tlw backdrop hiding it.
Lua Code:
  1. local bd = WINDOW_MANAGER:CreateControlFromVirtual("comboBox"..name, tlw, "ZO_DefaultBackdrop")
  2. bd:SetAnchorFill()

Only going by what you said, it sounds like you don't need the backdrop at all, since the parent control has its own backdrop where the dropdowns will be placed.

If your just wanting to use the backdrop to outline a box/area around the dropdown then you should probably do something like:
Lua Code:
  1. local comboName = "combo"..name
  2. local comboBox = WINDOW_MANAGER:CreateControlFromVirtual(comboName , tlw, "ZO_ComboBox")
  3. comboBox:SetDimensions(150, 30)
  4. comboBox:ClearAnchors()
  5. comboBox:SetAnchor(TOPLEFT, tlw, TOPLEFT, x, y)
  6.  
  7.  
  8. -- make the backdrop parent the comboBox
  9. local bd = WINDOW_MANAGER:CreateControlFromVirtual("comboBox"..name, comboName , "ZO_DefaultBackdrop")
  10. -- Now using achorFill would make the backdrop the same size as the comboBox, although
  11. -- that means it probably wouldn't show up because its not big enough, it will
  12. -- be hidden behind the comboBox
  13. -- bd:SetAnchorFill()
  14. -- so add some padding and anchor it around the comboBox
  15. bd:SetAnchor(TOPLEFT, comboBox, TOPLEFT, -10, -10)
  16. bd:SetAnchor(BOTTOMRIGHT, comboBox, BOTTOMRIGHT, 10, 10)

Last edited by circonian : 11/24/15 at 02:35 AM.
  Reply With Quote
11/24/15, 09:55 AM   #3
Weaselkit
Join Date: Nov 2015
Posts: 3
You sir, are a gentleman and a scholar. I cannot believe I couldn't figure that out! The code is just screaming the obvious. You were right in your assumption that I already had a tlw and every time I was calling that function, it was in fact creating a new twl and filling the original.

<3
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » CreateControlFromVirtual parameters


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off