Thread Tools Display Modes
05-20-17, 12:53 PM   #1
Asalas77
A Murloc Raider
Join Date: May 2017
Posts: 9
Creating a frame within a frame

Hello, I am trying to create a dropdown menu using this tutorial http://wow.gamepedia.com/Using_UIDropDownMenu

But instead of having in on UIParent, I want to stick it inside my addon frame.

Here's my code, i changed 'UIParent' to 'Main' (my frame) as 3rd argument but the list is still drawn on on parent. I tried I to write 'Main:CreateFrame...' but the dropdown list dissapears completely.

lua Code:
  1. raids = {'Naxxramas','Vault of Archavon','Obsidian Sanctum','Ulduar','The Eye of Eternity','Trial of the Crusader','Onyxia\'s Lair','Icecrown Citadel','Ruby Sanctum'}
  2. raid_values ={'naxx','voa','os','uldu','eoe','toc','onyxia','icc','rs'}
  3.  
  4. local raid;
  5.  
  6. local dropDown = CreateFrame("Frame", "raidDrop", Main, "UIDropDownMenuTemplate")
  7. dropDown:SetPoint("CENTER",0,0)
  8. UIDropDownMenu_SetWidth(dropDown, 80)
  9. UIDropDownMenu_SetText(dropDown,raid)
  10.  
  11.  
  12. UIDropDownMenu_Initialize(dropDown, function(self, level, menuList)
  13.  local info = UIDropDownMenu_CreateInfo()
  14.   for i=1,9 do
  15.    info.text, info.arg1, info.checked = raids[i], raid_values[i], false
  16.     info.func = self.SetValue
  17.    UIDropDownMenu_AddButton(info)
  18.  end
  19. end)
  20.  
  21.  
  22. function dropDown:SetValue(newValue)
  23.  raid = newValue
  24.  UIDropDownMenu_SetText(dropDown,raid)
  25.  CloseDropDownMenus()
  26. end

Last edited by Asalas77 : 05-20-17 at 01:03 PM.
 
05-20-17, 01:38 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
If Main is the name of your frame, it needs to be enclosed within quotes. (and you should use a more unique name to avoid potential namespace conflict) Otherwise, the Main variable is not available in this scope.

If that doesn't help, you should include all of your code, including the Main frame.
__________________
Grab your sword and fight the Horde!
 
05-20-17, 01:56 PM   #3
Asalas77
A Murloc Raider
Join Date: May 2017
Posts: 9
Ok so here's the full code.

lfg.lua
Lua Code:
  1. -- Author      : adamz
  2. -- Create Date : 5/20/2017 2:16:57 PM
  3. function OnLoad()
  4.      Main:Show();
  5.      local line = Main:CreateTexture()
  6.     line:SetTexture(.6 ,.6, .6, .4)
  7.     line:SetSize(170, 1)
  8.     line:SetPoint("TOP", 0,-207.5)
  9.  
  10. end
  11.  
  12. function MinimapButton_OnClick()
  13.       if not Main:IsVisible() then
  14.          Main:Show();
  15.      else
  16.          Main:Hide();
  17.      end
  18. end
  19.  
  20. SLASH_LFGSHOW1 = '/lfg';
  21. function SlashCmdList.LFGSHOW()
  22. Main:Show();
  23. end
  24.  
  25.  
  26. -- RAID SETTINGS --
  27.  
  28. raids = {'Naxxramas','Vault of Archavon','Obsidian Sanctum','Ulduar','The Eye of Eternity','Trial of the Crusader','Onyxia\'s Lair','Icecrown Citadel','Ruby Sanctum'}
  29. raid_values ={'naxx','voa','os','uldu','eoe','toc','onyxia','icc','rs'}
  30.  
  31. local raid;
  32. local raidSize =10;
  33. local tank =2;
  34. local heal = 2;
  35. local dps = 6;
  36.  
  37. local dropDown = CreateFrame("Frame", "raidDrop", Main, "UIDropDownMenuTemplate")
  38. dropDown:SetPoint("TOPLEFT",0,0)
  39. UIDropDownMenu_SetWidth(dropDown, 80)
  40. UIDropDownMenu_SetText(dropDown,raid)
  41.  
  42. UIDropDownMenu_Initialize(dropDown, function(self, level, menuList)
  43.  local info = UIDropDownMenu_CreateInfo()
  44.   for i=1,9 do
  45.    info.text, info.arg1, info.checked = raids[i], raid_values[i], false
  46.     info.func = self.SetValue
  47.    UIDropDownMenu_AddButton(info)
  48.  end
  49. end)
  50.  
  51. function dropDown:SetValue(newValue)
  52.  raid = newValue
  53.  UIDropDownMenu_SetText(dropDown,raid)
  54.  CloseDropDownMenus()
  55. end
  56.  
  57.  
  58. function updateCount()
  59.     tankCount:SetText(tostring(tank));
  60.     healCount:SetText(tostring(heal));
  61.     dpsCount:SetText(tostring(dps));
  62. end
  63.  
  64.  function Button10_OnClick()
  65.     raidSize = 10;
  66.     tank = 2;
  67.     heal = 2;
  68.     dps = 6;
  69.     updateCount();
  70. end
  71.  
  72. function Button25_OnClick()
  73.     raidSize = 25;
  74.     tank = 2;
  75.     heal = 5;
  76.     dps = 17;
  77.     updateCount();
  78. end
  79.  
  80.  function tankMinus_OnClick()
  81.  tank = tank -1;
  82. updateCount();
  83.  end
  84.  
  85. function tankPlus_OnClick()
  86.  tank = tank +1;
  87. updateCount();
  88.  end
  89.  
  90. function healMinus_OnClick()
  91.  heal = heal -1;
  92. updateCount();
  93. end
  94.  
  95.  function healPlus_OnClick()
  96.   heal = heal +1;
  97. updateCount();
  98.  end
  99.  
  100. function dpsMinus_OnClick()
  101.  dps = dps -1;
  102. updateCount();
  103.  end
  104.  
  105. function dpsPlus_OnClick()
  106.  dps = dps +1;
  107. updateCount();
  108.  end
  109.  
  110. function sendButton_OnClick()
  111. msg = dropDown:GetValue() .. raidSize .. 'need ' .. tank .. 'x tank, ' .. heal .. 'x heal' .. 'x dps' .. '';
  112.     SendChatMessage(msg,"CHANNEL", DEFAULT_CHAT_FRAME.editBox.languageID, GetChannelName(channel:GetText()));
  113. end


lfg.xml
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Script file="lfg.lua" />
 <Frame name="Main" movable="true" enableMouse="true">
		<Size x="200" y="325" />
		<Anchors>
			<Anchor point="CENTER" x="0" y="0" />
		</Anchors>
		<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
			<BackgroundInsets>
				<AbsInset left="10" right="10" top="10" bottom="10" />
			</BackgroundInsets>
			<TileSize>
				<AbsValue val="32" />
			</TileSize>
			<EdgeSize>
				<AbsValue val="32" />
			</EdgeSize>
		</Backdrop>
		<Layers>
			<Layer level="OVERLAY">
				<FontString inherits="GameFontNormalSmall" text="Raid">
					<Anchors>
						<Anchor point="TOPLEFT" x="20" y="-20" />
					</Anchors>
				</FontString>
				
				
				
				<FontString inherits="GameFontNormalSmall" text="Tank">
					<FontHeight val="10"/>
					<Anchors>
						<Anchor point="TOPLEFT" x="20" y="-60" />
					</Anchors>
				</FontString>
				<FontString inherits="GameFontNormalSmall" text="Heal">
					<Anchors>
						<Anchor point="TOPLEFT" x="20" y="-80" />
					</Anchors>
				</FontString>
				<FontString inherits="GameFontNormalSmall" text="Dps">
					<Anchors>
						<Anchor point="TOPLEFT" x="20" y="-100" />
					</Anchors>
				</FontString>
				
				
				
				
				<FontString inherits="GameFontNormalSmall" text="Min GS">
					<Anchors>
						<Anchor point="TOPLEFT" x="20" y="-160" />
					</Anchors>
				</FontString>
				<FontString inherits="GameFontNormalSmall" text="Info">
					<Anchors>
						<Anchor point="TOPLEFT" x="20" y="-180" />
					</Anchors>
				</FontString>
				<FontString inherits="GameFontNormalSmall" text="Teamspeak">
					<Anchors>
						<Anchor point="TOPLEFT" x="20" y="-140" />
					</Anchors>
				</FontString>
				
				
				
				<FontString inherits="GameFontNormalSmall" text="Channel name">
					<Anchors>
						<Anchor point="TOPLEFT" x="20" y="-220" />
					</Anchors>
				</FontString>
				<FontString inherits="GameFontNormalSmall" text="Auto send">
					<Anchors>
						<Anchor point="TOPLEFT" x="20" y="-240" />
					</Anchors>
				</FontString>
				<FontString inherits="GameFontNormalSmall" text="Msg delay">
					<Anchors>
						<Anchor point="TOPLEFT" x="20" y="-260" />
					</Anchors>
				</FontString>
			</Layer>
		</Layers>
		<Frames>
		
			<Button name="10_Button" inherits="UIPanelButtonTemplate" text="10">
					<Size x="30" y="15" />	<NormalFont style="GameFontNormalSmall"/>
				
					<Anchors>
						<Anchor point="TOPLEFT" x="100" y="-40" />
					</Anchors>
					<Scripts>
						<OnClick>
							Button10_OnClick()
						</OnClick>
					</Scripts>
				</Button>
			<Button name="25_Button" inherits="UIPanelButtonTemplate" text="25">
					<Size x="30" y="15" />
					<NormalFont style="GameFontNormalSmall"/>
					<Anchors>
					
						<Anchor point="TOPLEFT" x="140" y="-40" />
					</Anchors>
					<Scripts>
						<OnClick>
							Button25_OnClick()
						</OnClick>
					</Scripts>
				</Button>
			<Button name="tankMinus" inherits="UIPanelButtonTemplate" text="-">
				<Size x="15" y="15" />
				<Anchors>
					<Anchor point="TOPLEFT" x="100" y="-60" />
				</Anchors>
				<Scripts>
					<OnClick>
						tankMinus_OnClick()
					</OnClick>
				</Scripts>
			</Button>
			<Button name="tankPlus" inherits="UIPanelButtonTemplate" text="+">
				<Size x="15" y="15" />
				<Anchors>
					<Anchor point="TOPLEFT" x="160" y="-60" />
				</Anchors>
				<Scripts>
					<OnClick>
						tankPlus_OnClick()
					</OnClick>
				</Scripts>
			</Button>
			<Button name="healMinus" inherits="UIPanelButtonTemplate" text="-">
				<Size x="15" y="15" />
				<Anchors>
					<Anchor point="TOPLEFT" x="100" y="-80" />
				</Anchors>
				<Scripts>
					<OnClick>
						healMinus_OnClick()
					</OnClick>
				</Scripts>
			</Button>
			<Button name="healPlus" inherits="UIPanelButtonTemplate" text="+">
				<Size x="15" y="15" />
				<Anchors>
					<Anchor point="TOPLEFT" x="160" y="-80" />
				</Anchors>
				<Scripts>
					<OnClick>
						healPlus_OnClick()
					</OnClick>
				</Scripts>
			</Button>
			<Button name="dpsMinus" inherits="UIPanelButtonTemplate" text="-">
				<Size x="15" y="15" />
				<Anchors>
					<Anchor point="TOPLEFT" x="100" y="-100" />
				</Anchors>
				<Scripts>
					<OnClick>
						dpsMinus_OnClick()
					</OnClick>
				</Scripts>
			</Button>
			<Button name="dpsPlus" inherits="UIPanelButtonTemplate" text="+">
				<Size x="15" y="15" />
				<Anchors>
					<Anchor point="TOPLEFT" x="160" y="-100" />
				</Anchors>
				<Scripts>
					<OnClick>
						dpsPlus_OnClick()
					</OnClick>
				</Scripts>
			</Button>
			<Button name="closeButton" inherits="UIPanelButtonTemplate" text="Close">
				<Size x="80" y="20" />	<NormalFont style="GameFontNormalSmall"/>
				
				<Anchors>
					<Anchor point="TOPLEFT" x="100" y="-290" />
				</Anchors>
				<Scripts>
					<OnClick>
						MinimapButton_OnClick()
					</OnClick>
				</Scripts>
			</Button>
			<Button name="sendButton" inherits="UIPanelButtonTemplate" text="Send">
				<Size x="80" y="20" />	<NormalFont style="GameFontNormalSmall"/>
				
				<Anchors>
					<Anchor point="TOPLEFT" x="20" y="-290" />
				</Anchors>
				<Scripts>
					<OnClick>
						sendButton_OnClick();
					</OnClick>
				</Scripts>
			</Button>
			
			<EditBox name="tankCount" autoFocus="false" inherits="InputBoxTemplate">
			  <Size x="20" y="20" /> 
				<Anchors>
					<Anchor point="TOPLEFT" x="130" y="-57.5" /> 
				</Anchors> 
			 </EditBox>
			<EditBox name="healCount" autoFocus="false" inherits="InputBoxTemplate">
				 <Size x="20" y="20" /> 
				<Anchors>
					<Anchor point="TOPLEFT" x="130" y="-77.5" /> 
				</Anchors> 
			 </EditBox>
			<EditBox name="dpsCount" autoFocus="false" inherits="InputBoxTemplate"> 
				 <Size x="20" y="20" /> 
				 <Anchors> 
				 <Anchor point="TOPLEFT" x="130" y="-97.5" />
				 </Anchors> 
			 </EditBox> 
			<EditBox name="delay" autoFocus="false" inherits="InputBoxTemplate">
				<Size x="20" y="20" />
				 <Anchors> 
				 <Anchor point="TOPLEFT" x="130" y="-257.5" /> 
			 </Anchors> 
			 </EditBox> 
			<EditBox name="gs" autoFocus="false" inherits="InputBoxTemplate">
				<Size x="40" y="20" />
				 <Anchors> 
				 <Anchor point="TOPLEFT" x="120" y="-157.5" /> 
			 </Anchors> 
			 </EditBox> 
			<EditBox name="info" autoFocus="false" inherits="InputBoxTemplate">
				<Size x="80" y="20" />
				 <Anchors> 
				 <Anchor point="TOPLEFT" x="100" y="-177.5" /> 
			 </Anchors> 
			 </EditBox> 
			<EditBox name="channel" autoFocus="false" inherits="InputBoxTemplate">
				<Size x="80" y="20" />
				 <Anchors> 
				 <Anchor point="TOPLEFT" x="100" y="-217.5" /> 
			 </Anchors> 
			 </EditBox> 
		
			 <CheckButton name="teamspeakCheck" inherits="UICheckButtonTemplate" id="1"> 
				 <Size x="20" y="20" /> 
				<Anchors> 
					 <Anchor point="TOPLEFT" x="127.5" y="-137.5" /> 
			 </Anchors> 
			</CheckButton> 
			 <CheckButton name="autosendCheck" inherits="UICheckButtonTemplate" id="2"> 
				 <Size x="20" y="20" /> 
				<Anchors> 
				<Anchor point="TOPLEFT" x="127.5" y="-237.5" />
				 </Anchors> 
			</CheckButton> 

		</Frames>
		<Scripts>
				<OnLoad>
				tinsert(UISpecialFrames, self:GetName());
				OnLoad();
				self:RegisterForDrag("LeftButton");
				tankCount:SetScript("OnEscapePressed", function(self)
						 self:ClearFocus()
						end)
				healCount:SetScript("OnEscapePressed", function(self)
						self:ClearFocus()
						end)
				dpsCount:SetScript("OnEscapePressed", function(self)
						self:ClearFocus()
						end)
			</OnLoad>
		<OnDragStart> 
				self:StartMoving();
			</OnDragStart>
			<OnDragStop>
				self:StopMovingOrSizing();
			</OnDragStop>
		</Scripts>
	</Frame>
	
	<Button name="MinimapButton" parent="Minimap" movable="true" enableMouse="true">
		<Size>
			<AbsDimension x="33" y="33" />
		</Size>
		<Anchors>
			<Anchor point="TOPLEFT" />
		</Anchors>
		<Layers>
			<Layer level="BACKGROUND">
				<Texture name="MyMod_MinimapButton_Icon" file="Interface\Icons\INV_Misc_QuestionMark">
					<Size>
						<AbsDimension x="21" y="21" />
					</Size>
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset>
								<AbsDimension x="7" y="-6" />
							</Offset>
						</Anchor>
					</Anchors>
				</Texture>
			</Layer>
			<Layer level="OVERLAY">
				<Texture file="Interface\Minimap\MiniMap-TrackingBorder">
					<Size>
						<AbsDimension x="56" y="56" />
					</Size>
					<Anchors>
						<Anchor point="TOPLEFT" />
					</Anchors>
				</Texture>
			</Layer>
		</Layers>
		<Scripts>
			<OnLoad>
				this:RegisterForClicks("LeftButtonUp","RightButtonUp")
				</OnLoad>
			<OnClick>
				MinimapButton_OnClick()
			</OnClick>
		</Scripts>
		<HighlightTexture file="Interface\Minimap\UI-Minimap-ZoomButton-Highlight" alphaMode="ADD" />
	</Button>
</Ui>
That's it.

Sorry if this is some basic stuff I'm missing, I just started learning lua today.
 
05-20-17, 02:02 PM   #4
Kakjens
A Cliff Giant
Join Date: Apr 2017
Posts: 75
Probably need to see toc file as well.
 
05-20-17, 02:04 PM   #5
Asalas77
A Murloc Raider
Join Date: May 2017
Posts: 9
There's really not much to it.
Code:
## Title: LFG Assistant
## Version: 1.0
## Author: adamz
## Interface: 30300

lfg.xml
 
05-20-17, 03:59 PM   #6
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Your script file loads before the Main frame is created. One way to fix it that require minimal change would be to add raidDrop:SetParent(Main) to OnLoad. Might need to do SetPoint after that. Not sure.
__________________
Grab your sword and fight the Horde!
 
05-20-17, 04:50 PM   #7
Asalas77
A Murloc Raider
Join Date: May 2017
Posts: 9
ok that worked thank you for your help
 
05-20-17, 05:14 PM   #8
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Asalas77 View Post
There's really not much to it.
Code:
## Title: LFG Assistant
## Version: 1.0
## Author: adamz
## Interface: 30300

lfg.xml
Originally Posted by ctepik View Post
Mb can work macro like this

3.3.5

I can't help but notice those are not the latest version of the game
 
05-21-17, 01:40 AM   #9
Yukyuk
A Chromatic Dragonspawn
 
Yukyuk's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2015
Posts: 179
Originally Posted by Asalas77 View Post
There's really not much to it.
Code:
## Title: LFG Assistant
## Version: 1.0
## Author: adamz
## Interface: 30300

lfg.xml
Why does the toc file say ## Interface: 30300 ?
Oops, Ketho also made the same comment :-)
__________________
Better to fail then never have tried at all.
 
05-21-17, 02:20 AM   #10
Asalas77
A Murloc Raider
Join Date: May 2017
Posts: 9
Yeah, I'm writing this for WotLK
 
05-21-17, 04:53 AM   #11
humfras
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 131
Originally Posted by Asalas77 View Post
Yeah, I'm writing this for WotLK
Please note that
Originally Posted by Cairenn View Post
Discussion of Private Servers, in any manner other than theoretical, is completely against our rules. We are an Official Fan Site. We follow Blizzard's rules, on top of our own rules.

Threads requesting assistance with Private Servers get locked. Repeated postings get you banned.
http://www.wowinterface.com/forums/s...14&postcount=3
__________________
Author of VuhDo CursorCastBar OptiTaunt Poisoner RaidMobMarker
 
05-21-17, 12:01 PM   #12
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
What he said ^^.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

 

WoWInterface » Developer Discussions » Lua/XML Help » Creating a frame within a frame

Thread Tools
Display Modes

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