Thread Tools Display Modes
08-28-09, 04:56 PM   #1
spiel2001
nUI's Author
 
spiel2001's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 7,724
Setting up Key Bindings...

Originally Posted by lairdofdeath
ive benn looking into adding key bindings to the profesions addon i did and was hoping you could help me learn how

i pretty sure i will have to add a .xml file to it but im not sure what if anything im saposed to add to the code itself or ware im saposed to add it at

thanx in advance for your time
You need a couple of things to make key bindings work. First, you'll need an xml file that defines what key bindings your addon supports. I've attached the key binding file for nUI to this message. Each line in the file defines the bindings for a single button. The first line of each section or group of buttons also references the text label that will be displayed...

<Binding name="CLICK nUI_ActionBar_Button1:LeftButton" description="nUI_ACTIONBAR1" header="nUI_ACTIONBAR">--[[ dummy ]]</Binding>

The binding name defines the type of binding (CLICK), the button the key binding belongs to (nUI_ActionBar_Button1), the type of click (LeftButton), the key binding label for that button (nUI_ACTIONBAR1) and optionally a heading (nUI_ACTIONBAR) -- a new "group" of buttons is displayed in the key binding frame for each "header" in the XML file... look at this file and look at the key binding window and you'll start to connect the dots mentally.

Note that the name of "Bindings.xml" is case dependent on some systems. The file should be located in the root directory for your addon and it does not need to be included in the TOC. WoW will just load it if it is there.

The second thing you need is the glue code that matches the description and header to the text strings that are displayed for them.

This piece of code defines what the text label for the button will be in the key binding window..

_G["BINDING_NAME_CLICK "nUI_ActionBar_Button1:LeftButton"] = "Button #1";

And this piece of code sets the heading for the group of buttons...

_G["BINDING_HEADER_nUI_ACTIONBAR] = "nUI: Main Bar / Action Page 1";

If you look at the attached nUI_ButtonBar.lua you can see where I am setting these values up for the action bars.
Attached Files
File Type: xml Bindings.xml (15.6 KB, 1189 views)
File Type: lua nUI_ButtonBar.lua (28.9 KB, 1132 views)
__________________

What people don't get is that I am, ultimately, an artist at heart.
My brush has two colors, 1 and 0, and my canvas is made of silicon.



Official nUI Web Site: http://www.nUIaddon.com
Official nUI Support Forum: http://forums.nUIaddon.com
My day job: http://www.presidio.com/
 
 

WoWInterface » Featured Projects » nUI, MozzFullWorldMap and PartySpotter » Customization » nUI: Developer Chat » Setting up Key Bindings...

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