Thread Tools Display Modes
10-14-05, 03:14 PM   #1
Vex
Premium Member
 
Vex's Avatar
Join Date: Sep 2005
Posts: 41
showing a frame when you click an option in the dropdown menu

here's my LUA script
http://www.vexiphne.net/DiscordMini.html

basically the functionality i'm looking for is when you click a button thats attached to the minimap frame, it opens a dropdown menu and lets you pick which config window to show. I'm trying to eliminate the need to type in slash commands every time i want to make a change in one of my mod's settings.

the minimap button works, it shows a dropdownmenu, but i can't get the individual options to trigger an event ( showing the frame) ... the events only occur when i click the actual minimap button. events being, showing 5 different option windows at one time.

any help would be much appreciated.
  Reply With Quote
10-14-05, 06:01 PM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
function ShowFrame_OnClick(frame)
-- frame:Show(); -- this will show all frames listed in the dropdownmenu as soon as i click
-- the minimap button, instead of showing the specified frame when i click on its name.
end

info = {};
info.text = "Discord Action Bars";
info.value = "DAB_Options";
info.notCheckable = 1;
info.func = ShowFrame_OnClick(DAB_Options);
UIDropDownMenu_AddButton(info);
What's happening is ShowFrame_OnClick(DAB_Options) runs, but only when it's assigned in the above initialization. ShowFrame_OnClick returns nil so info.func equals nil when the user gets around to clicking that dropdown button.

You'll want to do something like:

info.func = ShowFrame_OnClick

That will make info.func==the function instead of info.func==the result of the function

Of course you'll need to determine which option was chosen some other way. I have very little experience working with the default drop-downs so can't answer that part, but there's certainly a way.

edit: this is a clunky way to work around it. There's surely a smoother method:

info.func = function() ShowFrame_OnClick(DAB_Options) end

It wraps the function call around a function itself. You can also experiment with dropping the parameter to the function:

info.func = ShowFrame_OnClick

function ShowFrame_OnClick()
local id = this:GetID()
DEFAULT_CHAT_FRAME:AddMessage("You chose option "..id)
end

Last edited by Gello : 10-14-05 at 06:08 PM.
  Reply With Quote
10-14-05, 07:30 PM   #3
Vex
Premium Member
 
Vex's Avatar
Join Date: Sep 2005
Posts: 41
that easy x_X

thank you so so so so so so so so so so so so so (sox100 more ) much.

eet verks!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » showing a frame when you click an option in the dropdown menu


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