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
03-26-13, 08:29 AM   #7
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Dridzt View Post
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.
Yeah table could work, but it would be harder to code that.
  Reply With Quote
03-26-13, 08:55 AM   #8
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Okay, when i store russian localized strings in the info.text then this is what it looks like:

http://i.imgur.com/XfIrvFv.jpg

Is this because the inherits="GameFontNormal" cant handle these characters, and it will be fine on a russian client, or some kinda another bug? Or i did something wrong? I saved everything in utf8 and stuff.
  Reply With Quote
03-26-13, 11:04 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Question marks mean that the font you are using doesn't support those characters. If you're loading Russian characters in the English client, and you're using the default Friz Quadrata font, you will get question marks. If you want to show Russian characters in a non-Russian game client, you need make sure the font you're using includes those characters.

Arial Narrow supports both Latin and Cyrillic characters.

The version of Friz Quadrata loaded in English clients only supports Latin characters, while the version loaded in Russian clients only supports Cyrillic.

The Friz Quadrata lookalikes used by Korean and Chinese clients support both, so if you like the look of Friz Quadrata, you might look into those:

Code:
2002.ttf       2002
2002B.ttf      2002 Bold
ARHei.ttf      AR CrystalzcuheiGBK Demibold
ARKai_C.ttf    AR ZhongkaiGBK Medium (Combat)
ARKai_T.ttf    AR ZhongkaiGBK Medium
(Remember, every client includes the font files for every locale, even if it doesn't load them.)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 03-26-13 at 11:10 PM.
  Reply With Quote
03-27-13, 07:48 AM   #10
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Phanx View Post
Question marks mean that the font you are using doesn't support those characters. If you're loading Russian characters in the English client, and you're using the default Friz Quadrata font, you will get question marks. If you want to show Russian characters in a non-Russian game client, you need make sure the font you're using includes those characters.

Arial Narrow supports both Latin and Cyrillic characters.

The version of Friz Quadrata loaded in English clients only supports Latin characters, while the version loaded in Russian clients only supports Cyrillic.

The Friz Quadrata lookalikes used by Korean and Chinese clients support both, so if you like the look of Friz Quadrata, you might look into those:

Code:
2002.ttf       2002
2002B.ttf      2002 Bold
ARHei.ttf      AR CrystalzcuheiGBK Demibold
ARKai_C.ttf    AR ZhongkaiGBK Medium (Combat)
ARKai_T.ttf    AR ZhongkaiGBK Medium
(Remember, every client includes the font files for every locale, even if it doesn't load them.)
Okay, so just like i tought, since i use the inhertited text with xml, i need to create a custom template for the font i want to use which supports all characters? And why is it shows the enable button text and the dropdown label text correctly, but not the dropdown menus? Also any1 could show me a Custom xml font template?

Also if i like get the Friz Quadrata Cyrillic version is it gonna show Latin characters properly?

Last edited by Resike : 03-27-13 at 07:51 AM.
  Reply With Quote
03-27-13, 08:26 AM   #11
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
The problem i see, the 2002 only supports Korean, and the ARHei only supports Chinesee characters.
I would like an all in one font.

Last edited by Resike : 03-27-13 at 09:14 AM.
  Reply With Quote
03-27-13, 09:31 AM   #12
TSquared
Big Daddy!
Join Date: May 2008
Posts: 527
If you are not "mixing" regions in one string (ie: Chinese & Russian) you can create a fall-back system similar to what WoW does with Chat. Look in FontStyleOverrides.xml for examples.

The key parts are:
"alternateTo" to point to the base font to override.
"alternateAlphabetID" which is the alphabet that triggers it (0=Korean, 1=Chinese, 3=Russian; aka: Hangeul,
Hanzi, Cyrillic)

Last edited by TSquared : 03-27-13 at 09:39 AM.
  Reply With Quote
03-27-13, 09:46 AM   #13
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by TSquared View Post
If you are not "mixing" regions in one string (ie: Chinese & Russian) you can create a fall-back system similar to what WoW does with Chat. Look in FontStyleOverrides.xml for examples.

The key parts are:
"alternateTo" to point to the base font to override.
"alternateAlphabetID" which is the alphabet that triggers it (0=Korean, 1=Chinese, 3=Russian; aka: Hangeul,
Hanzi, Cyrillic)
I see, but how do i trigger the change? Like when i select a different language from the dropdown menu?
Just simply change the alternateAlphabetID?
Alsi it's 0-1-2 and how do i change back to the normal latin font?

Last edited by Resike : 03-27-13 at 09:50 AM.
  Reply With Quote
03-27-13, 10:56 AM   #14
TSquared
Big Daddy!
Join Date: May 2008
Posts: 527
The system triggers it based the the Unicode value. You are just setting up a "configuration."
If it's Russian use this font, if it's Latin use the base font, etc.
  Reply With Quote
03-27-13, 11:51 AM   #15
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Okay i managed to change the font of the dropdown menus with the info.fontObject but, the selected dropdown's name still wrong, also the tooltips and some other inherited strings. Any tips to fix thoose?

http://tinypic.com/view.php?pic=25rmb04&s=6

Edit: Okay it took me like 5 hours, but i managed to fix every issues now.

Here is the original project btw:

https://github.com/Resike/PVPSound

Last edited by Resike : 04-04-13 at 03:40 PM.
  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