Thread Tools Display Modes
01-13-08, 10:17 AM   #1
LucifersHand
A Murloc Raider
 
LucifersHand's Avatar
Join Date: Dec 2007
Posts: 5
Issues with DropDown not working correctly.

I am working on my first WOW mod. I am familiar with other programming languages but I am trying to get the hang of LUA and the XML commands.

In my mod I am trying to add a drop down where the user can select other Profiles to view their information.

I was going through the FrameXML files that Blizzard gives out in the Dev Kit and found the commands for the DropDown in the Options.

the button shows on my screen but it does not show the profile name. when you click on the button I do get the dropdown with my profiles names. when i click on a profile it does run the command set for it and does update the Mod.

But the dropdown list does not go away and the selected profile does not get displayed.

Is there something im missing?

Copied from the OptionsFrame.xml
Code:
<Frame name="OptionsFrameRefreshDropDown" inherits="UIDropDownMenuTemplate" id="2">
     <Anchors>
          <Anchor point="TOPLEFT" relativeTo="OptionsFrameResolutionDropDown" relativePoint="BOTTOMLEFT">
               <Offset x="0" y="-10"/>
          </Anchor>
     </Anchors>
     <Layers>
          <Layer level="BACKGROUND">
               <FontString name="$parentLabel" inherits="GameFontNormalSmall" text="REFRESH_RATE">
                    <Anchors>
                         <Anchor point="BOTTOMLEFT" relativePoint="TOPLEFT">
                              <Offset x="21" y="0"/>
                         </Anchor>
                    </Anchors>
               </FontString>
          </Layer>
     </Layers>
     <Scripts>
          <OnLoad>
               OptionsFrameRefreshDropDown_OnLoad();
          </OnLoad>
          <OnShow>
               OptionsFrameRefreshDropDown_OnLoad();
          </OnShow>
          <OnEnter>
               GameTooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
	       GameTooltip:SetText(OPTION_TOOLTIP_USE_REFRESH, nil, nil, nil, nil, 1);
          </OnEnter>
          <OnLeave>
               GameTooltip:Hide();
          </OnLeave>
     </Scripts>
</Frame>
My Code
Code:
<Frame name="$parent_ProfileDropDown" inherits="UIDropDownMenuTemplate" enableMouse="true">
     <Anchors>
          <Anchor point="TOPRIGHT">
               <Offset x="-165" y="-22"/>
          </Anchor>
     </Anchors>
     <Layers>
          <Layer level="ARTWORK">
               <FontString name="$parentLabel" inherits="GameFontNormalSmall" text="Profile">
                    <Anchors>
                         <Anchor point="BOTTOMRIGHT" relativePoint="TOPRIGHT">
                              <Offset x="100" y="0"/>
                         </Anchor>
                    </Anchors>
               </FontString>
          </Layer>
     </Layers>
     <Scripts>
          <OnLoad>
               SupplyList_ProfileDropDown_OnLoad();
          </OnLoad>
          <OnShow>
               SupplyLis_ProfileDropDown_OnLoad();
          </OnShow>
          <OnEnter>
               GameTooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
               GameTooltip:SetText("Select witch Profile you\nwould like to veiw.", nil, nil, nil, nil, 1);
          </OnEnter>
          <OnLeave>
               GameTooltip:Hide();
          </OnLeave>
     </Scripts>
</Frame>
Copied from the OptionsFrame.lua
Code:
function OptionsFrameResolutionDropDown_OnLoad()
	UIDropDownMenu_Initialize(this, OptionsFrameResolutionDropDown_Initialize);
	UIDropDownMenu_SetSelectedID(this, GetCurrentResolution(), 1);
	UIDropDownMenu_SetWidth(90, OptionsFrameResolutionDropDown);
end

function OptionsFrameResolutionDropDown_Initialize()
	OptionsFrameResolutionDropDown_LoadResolutions(GetScreenResolutions());	
end

function OptionsFrameResolutionDropDown_LoadResolutions(...)
	local info = UIDropDownMenu_CreateInfo();
	local resolution, xIndex, width, height;
	for i=1, select("#", ...) do
		resolution = (select(i, ...));
		xIndex = strfind(resolution, "x");
		width = strsub(resolution, 1, xIndex-1);
		height = strsub(resolution, xIndex+1, strlen(resolution));
		if ( width/height > 4/3 ) then
			resolution = resolution.." "..WIDESCREEN_TAG;
		end
		info.text = resolution;
		info.value = resolution;
		info.func = OptionsFrameResolutionButton_OnClick;
		info.checked = nil;
		UIDropDownMenu_AddButton(info);
	end
end
My Code
Code:
 
function SupplyList_ProfileDropDown_OnLoad()
	UIDropDownMenu_Initialize(SupplyList_ProfileDropDown, SupplyList_ProfileDropDown_Initialize);	
	UIDropDownMenu_SetSelectedID(SupplyList_ProfileDropDown, SL["PROFILE"]);
	UIDropDownMenu_SetWidth(90, SupplyList_ProfileDropDown);
end

function SupplyList_ProfileDropDown_Initialize()
	
	local info = UIDropDownMenu_CreateInfo();	
	for key, value in pairs(SL_PROFILES) do

		info.text = value;
		info.value = value;
		info.func = SupplyList_SetProfile(value);
		info.checked = nil;
		UIDropDownMenu_AddButton(info);
	end
end

function SupplyList_SetProfile(var)
	SL["PROFILE"] = var;

	SupplyList_GUIUpdate();
end
__________________
"I reject your reality, and substitute my own."
  Reply With Quote
01-13-08, 11:01 AM   #2
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
I have never tried working with DropDowns, however I just happened to notice this bit:

Code:
<OnShow>
      SupplyLis_ProfileDropDown_OnLoad();
</OnShow>
..which comes off a bit wierd with the missing "t"

Maybe it's just a copy+paste error though.
Hopefully someone better qualified could shed some light to it.

/Ailae
  Reply With Quote
01-13-08, 12:16 PM   #3
LucifersHand
A Murloc Raider
 
LucifersHand's Avatar
Join Date: Dec 2007
Posts: 5
/Smackshead

all this time ive been over looking that.

I guess that just shows that sometimes all that is needed is some fresh eyes.

I test it once im off work.

does anyone know if this could cause it to not show the text of the selected Profile?
__________________
"I reject your reality, and substitute my own."
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Issues with DropDown not working correctly.


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