Thread Tools Display Modes
11-11-10, 02:52 PM   #1
help137
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 31
Problem with UIDropDownMenu

Hey all. I'm fairly new to LUA programing (but not to programing in general) and I'm having an odd issue with a drop down menu in my addon's config screen that I'm hoping someone can shed some light on.

I'm using the UIDropDownMenuTemplate as the basis. Everything is working fine, except the button for the drop down menu is not large enough to hold the wider choices. The dropdown menu itself IS, it's just the button that is too narrow. I've tried two methods and three code positions to adjust it. None are working. I've reviewed every reference I can find on the UIDropDownMenu functionality and, according to them, either of these should work.

UIDropDownMenu_SetButtonWidth has no effect at all.
ConfigFontStyle:SetWidth, in both the places I've tried it, has the effect of causing the entire button to shift to the left 200 pixels as if I was setting an offset from an anchor point.

I'm going around in circles with this. It's just a cosmetic issue, but it looks sloppy!

Note: fonttable is simply a table with a list of fonts and nicely formatted names for them.

Code:
	local ConfigFontStyleLabel = config:CreateFontString( nil, "ARTWORK", "GameFontHighlight" );
	config.ConfigFontStyleLabel = ConfigFontStyleLabel;
	ConfigFontStyleLabel:SetPoint( "BOTTOMLEFT" , time,0,-40);
	ConfigFontStyleLabel:SetText( "|c00dfb802Font Style" );
	ConfigFontStyleLabel:Show();
	
	local ConfigFontStyle = CreateFrame("Frame", "MyAddon_FontPick", config, "UIDropDownMenuTemplate");
	config.ConfigFontStyle = ConfigFontStyle;
	ConfigFontStyle:SetPoint("RIGHT", ConfigFontStyleLabel,30, 0);
	--ConfigFontStyle:SetWidth(200); 
	ConfigFontStyle.initialize = function () 
	
	ConfigFontStyle:SetWidth(200); -- Let's try this here. 
	
	for i,v in ipairs(fonttable) do
		local fname, ffont = unpack(v);	
		info = UIDropDownMenu_CreateInfo()
		info.text = fname;
		info.func = config.ChangeFont;
		info.value = ffont;
		if(WhisperNotify_Config.Font == info.value) then
			info.checked = true;
		else
			info.checked = false;
		end
		UIDropDownMenu_AddButton(info)

	end --for	

	end;
	UIDropDownMenu_Initialize(ConfigFontStyle, ConfigFontStyle.initialize)
        UIDropDownMenu_SetSelectedValue(ConfigFontStyle,MyAddon_Config.Font );
--	UIDropDownMenu_SetButtonWidth(ConfigFontStyle, 200);
  Reply With Quote
11-11-10, 03:48 PM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
I'm not sure what UIDropDownMenu_SetButtonWidth is for, but
Code:
UIDropDownMenu_SetWidth(ConfigFontStyle, 200)
sets the width of the dropdown widget as expected.

The implementation of UIDropDownMenu_SetButtonWidth is

Code:
function UIDropDownMenu_SetButtonWidth(frame, width)
	if ( width == "TEXT" ) then
		width = _G[frame:GetName().."Text"]:GetWidth();
	end
	
	_G[frame:GetName().."Button"]:SetWidth(width);
	frame.noResize = 1;
end
Strange

Last edited by Duugu : 11-11-10 at 03:56 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Problem with UIDropDownMenu


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