Thread Tools Display Modes
06-14-06, 05:01 AM   #1
mixilpixil
A Murloc Raider
Join Date: Jun 2006
Posts: 6
Newbie trouble - Dropdowns (resolved) and EditBoxes (not resolved)

Greetings, fellow mod developers!

I am afraid I am yet another mod newbie. Thus, I have most likely made some rookie mistake and consequentially experienced the problems described below. I will genuinely appreciate any help you may be able to offer.

The first problem I have encountered is the fact that while my dropdowns behave properly, the text they display belongs to another dropdown box. My dropdowns display the appropriate entry when I load information from my SavedVariables, however they display the appropriate entry (say, number 2) of an entirely different list. I have seen them display zone names which correspond to the same ID from the world map zone list, as well as tapping into other dropdown boxes in the same manner. Other than this significant problem, they seem to work perfectly.

The second problem is that I am unable to create a fixed-size, multi-line editbox. The box changes its size as the text is entered and the text itself is not wrapped, instead being truncated with dots appended.

I will greatly appreciate any insight you can provide on these matters as they are crucial to my addon's development.
Thank you.

Last edited by mixilpixil : 06-14-06 at 03:22 PM.
  Reply With Quote
06-14-06, 10:13 AM   #2
Esamynn
Featured Artist
Premium Member
Featured
Join Date: Jan 2005
Posts: 395
For the dropdown problem: please post ALL of the relevent code.

For the editbox problem: take a look at some existing examples. Multiline editboxes are tricky and need to be enclosed in a ScrollFrame. I don't know anymore than that off hand because I have never created one for myself.
  Reply With Quote
06-14-06, 10:51 AM   #3
mixilpixil
A Murloc Raider
Join Date: Jun 2006
Posts: 6
Thank you for replying, jbcc.
Here is the XML for my dropdowns. It is identical for all of them, save for the names of course.

Code:
<Button name="SettingsPvPRanks" inherits="UIDropDownMenuTemplate">
		<Anchors>
			<Anchor point="TOPLEFT"/>
		</Anchors>
		
		<Scripts>
			<OnShow>
				UIDropDownMenu_Initialize(SettingsPvPRanks, InitialisePvPDropdown);
				UIDropDownMenu_SetSelectedID(SettingsPvPRanks, Settings["PVP_RANKS"]);
				UIDropDownMenu_SetWidth(200, SettingsPvPRanks);	
			</OnShow>
		</Scripts>
</Button>
And the supporting Lua code:
Code:
function HandlePvPDropdown()
	UIDropDownMenu_SetSelectedID(SettingsPvPRanks, this:GetID());
	Settings["PVP_RANKS"] = UIDropDownMenu_GetSelectedID(SettingsPvPRanks);
end


function InitialisePvPDropdown()
	local info = {};
	info.text = STRING_ALWAYS_SHOW_PVP;
	info.func = HandlePvPDropdown;
	info.checked = Settings["PVP_RANKS"] == 1;
	UIDropDownMenu_AddButton(info);

	local info = {};
	info.text = STRING_NEVER_SHOW_PVP;
	info.func = HandlePvPDropdown;
	info.checked = Settings["PVP_RANKS"] == 2;
	UIDropDownMenu_AddButton(info);

	local info = {};
	info.text = STRING_KNOWN_SHOW_PVP;
	info.func = HandlePvPDropdown;
	info.checked = Settings["PVP_RANKS"] == 3;
	UIDropDownMenu_AddButton(info);
end
Edit: Sorry, I forgot some code:

Code:
On the main frame <OnShow> event:
UIDropDownMenu_SetSelectedID(SettingsPvPRanks, Settings["PVP_RANKS"],true);
As for the editbox, I did look at examples in existing mods and my editbox is indeed contained within a ScrollChild element of a ScrollFrame.

Thank you for your help!

Last edited by mixilpixil : 06-14-06 at 10:58 AM.
  Reply With Quote
06-14-06, 03:20 PM   #4
mixilpixil
A Murloc Raider
Join Date: Jun 2006
Posts: 6
Well, I tried deleting the code on the frame's OnShow event and it seems to work. Thank you for your time though!

If someone could teach me a thing or two about editboxes, it would be nice.
Thank you!
  Reply With Quote
06-15-06, 12:09 PM   #5
Esamynn
Featured Artist
Premium Member
Featured
Join Date: Jan 2005
Posts: 395
Originally Posted by mixilpixil
Thank you for replying, jbcc.
Here is the XML for my dropdowns. It is identical for all of them, save for the names of course.
I agree, the <OnShow> code needed to go. Note that if you want to create a Dropdown frame object, but don't want that actual XML object to be visible (ie. you want to create a floating dropdown like you get when you right click on that TargetFrame, you need to put the following line in the frame's <OnLoad> script:
Code:
UIDropDownMenu_Initialize(this, nil, "MENU");
And the supporting Lua code:
Code:
function HandlePvPDropdown()
	UIDropDownMenu_SetSelectedID(SettingsPvPRanks, this:GetID());
	Settings["PVP_RANKS"] = UIDropDownMenu_GetSelectedID(SettingsPvPRanks);
end


function InitialisePvPDropdown()
	local info = {};
	info.text = STRING_ALWAYS_SHOW_PVP;
	info.func = HandlePvPDropdown;
	info.checked = Settings["PVP_RANKS"] == 1;
	UIDropDownMenu_AddButton(info);

	local info = {};
	info.text = STRING_NEVER_SHOW_PVP;
	info.func = HandlePvPDropdown;
	info.checked = Settings["PVP_RANKS"] == 2;
	UIDropDownMenu_AddButton(info);

	local info = {};
	info.text = STRING_KNOWN_SHOW_PVP;
	info.func = HandlePvPDropdown;
	info.checked = Settings["PVP_RANKS"] == 3;
	UIDropDownMenu_AddButton(info);
end
I feel the the InitialisePvPDropdown() function would be better designed like this:
Code:
local buttonInfo = { func = function() HandlePvPDropdown() end };
function InitialisePvPDropdown()
	buttonInfo.text = STRING_ALWAYS_SHOW_PVP;
	buttonInfo.checked = Settings["PVP_RANKS"] == 1;
	UIDropDownMenu_AddButton(buttonInfo);

	buttonInfo.text = STRING_NEVER_SHOW_PVP;
	buttonInfo.checked = Settings["PVP_RANKS"] == 2;
	UIDropDownMenu_AddButton(buttonInfo);

	buttonInfo.text = STRING_KNOWN_SHOW_PVP;
	buttonInfo.checked = Settings["PVP_RANKS"] == 3;
	UIDropDownMenu_AddButton(buttonInfo);
end
The changes have two advantages:
  • you aren't repeatedly creating and tossing table objects (the UIDropDownMenu_AddButton() function only pulls values out of the table you pass it, it doesn't required the table itself once it returns)
  • the wrapper function around the ["func"] entry in the table allows for hooking of the handler function without having to reassign the handler function to that table entry each and every time the initialize function runs
  Reply With Quote
06-15-06, 02:28 PM   #6
mixilpixil
A Murloc Raider
Join Date: Jun 2006
Posts: 6
Thank you for explaining these things! While I have dug into the UIDropDownMenu Lua file myself, the insights of an experienced mod author are always appreciated.

Just one last thing: can you point me in the direction of proper documentation of the WoW platform, or at least a resource from which I can learn about editboxes? Wowwiki.com is not enough, I'm afraid, and most of what I've done so far was based on learning from other mods, my experience as a programmer for other platforms and guesswork.

Any information regarding editboxes would be great.

Thank you!
  Reply With Quote
06-16-06, 10:40 AM   #7
Esamynn
Featured Artist
Premium Member
Featured
Join Date: Jan 2005
Posts: 395
I don't have any self-help resources to offer that can provide more than WowWiki. I'm assuming that you have downloaded the Blizzard AddOn Kit and you have extracted the FrameXML code so that you can examine it. There are several examples of EditBoxes in the default interface.

Experimentation is the way the most things are learned about the UI. A good place to ask questions is the IRC channel #wowi-lounge on freenode. There is a stickied forum post around here somewhere.
  Reply With Quote
06-16-06, 12:04 PM   #8
mixilpixil
A Murloc Raider
Join Date: Jun 2006
Posts: 6
Okay, I'll do some more experimenting. Thanks!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Newbie trouble - Dropdowns and EditBoxes


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