Thread Tools Display Modes
11-10-06, 10:32 AM   #1
davedontmind
A Defias Bandit
Join Date: Nov 2006
Posts: 2
Dropdown menu problems

I'm having trouble getting dropdown menus working correctly.

I have things *almost* working, but whenever I select a choice from the menu, all items from the one I selected up to the last one end up with a check mark beside them. What am I doing wrong?

Here is a very short test addon in its entirety that demonstrates the problem, in case anyone wants to try it.
First the .lua file:
Code:
function Test_DropDownInitialize()
    local entry = { func = Test_DropDownOnClick; }

    entry.text = "One";   entry.value = 101; UIDropDownMenu_AddButton(entry)
    entry.text = "Two";   entry.value = 102; UIDropDownMenu_AddButton(entry)
    entry.text = "Three"; entry.value = 103; UIDropDownMenu_AddButton(entry)
    entry.text = "Four";  entry.value = 104; UIDropDownMenu_AddButton(entry)
    
end

function Test_DropDownOnClick()
    UIDropDownMenu_SetSelectedID( Test_dropdown, this:GetID() );
end
The XML file:
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interface\FrameXML\UI.xsd">
  <Script file="Test.lua"/>
  <Frame name="TestMainFrame" frameStrata="HIGH" parent="UIParent" hidden="false" toplevel="true" enableMouse="true" movable="true"> 
	<Scripts>
	    <OnMouseDown>
		    this:StartMoving();
	    </OnMouseDown>
	    <OnMouseUp>
		    this:StopMovingOrSizing();
	    </OnMouseUp>
	</Scripts>

	<Size>
	    <AbsDimension x="200" y="100"/>
	</Size>

	<Anchors>
		<Anchor point="CENTER"/>
	</Anchors>

	<Backdrop name="$parentBackdrop" bgFile="Interface\TutorialFrame\TutorialFrameBackground" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
	    <EdgeSize>
		<AbsValue val="16"/>
	    </EdgeSize>
	    <TileSize>
		<AbsValue val="32"/>
	    </TileSize>
	    <BackgroundInsets>
		<AbsInset left="5" right="5" top="5" bottom="5"/>
	    </BackgroundInsets>
	</Backdrop>

	<Layers>
	    <Layer level="ARTWORK">
		<Texture file="Interface\DialogFrame\UI-DialogBox-Header">
		    <Size><AbsDimension x="256" y="64"/></Size>
		    <Anchors>
			<Anchor point="TOP">
			<Offset><AbsDimension x="0" y="12"/></Offset>
			</Anchor>
		    </Anchors>
		</Texture>
	    </Layer>
	</Layers>

	<Frames>
	    <Button name="Test_dropdown" inherits="UIDropDownMenuTemplate">
		<Size>
		    <AbsDimension x="48" y="24"/>
		</Size>
		<Anchors>
		    <Anchor point="TOPLEFT">
			<Offset><AbsDimension x="30" y="-40"/></Offset>
		    </Anchor>
		</Anchors>
		<Scripts>
		    <OnShow>
			UIDropDownMenu_Initialize( this, Test_DropDownInitialize );
		    </OnShow>
		</Scripts>
	    </Button>
	</Frames>

    </Frame>
</Ui>
And the TOC file:
Code:
## Title: Test
## Interface: 1800
## Version: 0.01
## Notes: Test
Test.xml
  Reply With Quote
12-24-06, 02:30 AM   #2
DMXGuru
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 11
function Test_DropDownInitialize()
local entry = { func = Test_DropDownOnClick; }

entry.text = "One"; entry.value = 101; UIDropDownMenu_AddButton(entry)
entry.text = "Two"; entry.value = 102; UIDropDownMenu_AddButton(entry)
entry.text = "Three"; entry.value = 103; UIDropDownMenu_AddButton(entry)
entry.text = "Four"; entry.value = 104; UIDropDownMenu_AddButton(entry)

end
You have a problem in your 'code'... there's a simple solution fortunately.

What's happening is there's a variable in the 'entry' array there that isn't being reset to nil to deselect it. Modify the lines so they look something like:

entry.text = "One"; entry.value = 101;
if (UIDropDownMenu_GetSelectedValue(Test_dropdown) == entry.value)
then entry.checked = true
else entry.checked = nil
end
UIDropDownMenu_AddButton(entry)

See if this helps.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Dropdown menu problems


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