Thread Tools Display Modes
03-26-13, 07:26 AM   #1
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Lua dropdown onclick function

How can you make a function which passes an argument when you click on something in the dropdown menu?

Like:
info.func = PVPSound_OptionsSetAddonLanguageOne(text)

function PVPSound_OptionsSetAddonLanguageOne(something)
--
end
  Reply With Quote
03-26-13, 07:36 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Lua Code:
  1. info.func = self.click --self is the dropdown menu

Under your dropdown creation you just define your click function.
Lua Code:
  1. --dropdownmenu
  2. local dropdownMenu = createBasicDropDownMenu()
  3. dropdownMenu.click = function(self)
  4.   PVPSound_OptionsSetAddonLanguageOne(self.value)
  5. end

I'm doing it this way for the oUF_Diablo config panel:
http://code.google.com/p/rothui/sour.../panel.lua#382
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 03-26-13 at 07:38 AM.
  Reply With Quote
03-26-13, 07:49 AM   #3
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
I would like to pass custom values not the info.value.

I found this workaround:

Code:
info.func = function(self)
	PVPSound_OptionsSetSoundPackOne("lolimastring")
end

function PVPSound_OptionsSetSoundPackOne(ohrlly)
--
end
  Reply With Quote
03-26-13, 07:58 AM   #4
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Aren't there some .argX for passing other arguments to your .func?
  Reply With Quote
03-26-13, 08:24 AM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Dridzt View Post
Aren't there some .argX for passing other arguments to your .func?
Yep, but thats pretty limited too, and only allows 2 arguments.
  Reply With Quote
03-26-13, 08:27 AM   #6
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Do argX have a limitation on the type passed?
Passing a table might be an option of getting more arguments there.

PS. I'm not suggesting a 'best' approach just exploring possibilities.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Lua dropdown onclick function

Thread Tools
Display Modes

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