Thread Tools Display Modes
10-30-14, 12:33 PM   #1
efortier
A Defias Bandit
Join Date: Oct 2014
Posts: 2
Problem binding key to a SecureActionButtonTemplate button

Hey guys,

I'm having problems having my key binding invoke the button's spell.

My bindings.xml shows in the game's Key Bindings and is as follow:

Code:
<Bindings>
  <Binding name="WTT_KEY1" description="Key 1" header="WTTOOLS">
    WTTKey1();
  </Binding>
</Bindings>
The WTTKey1() function is called, but that is not the result I'm looking for. I have a button defined as follow that I want invoked when the user presses the key bind:

Code:
IconDefault = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate")
IconDefault:SetAttribute("type", "spell")
IconDefault:SetAttribute("spell", "<spell>")
Where "<spell>" is the spell I want to cast, such as Devastate. The buttons work fine when I click on them, but I cannot get the binding working.

I'm pretty sure I'm missing an important bit, and I was not successful trying to make sense of other addons managing this.

Anyone can point me in the right direction with this?

Thanks!!

PS: I forgot to mention that I need to have the keybinding that the user can modify, and not hardcoded in he lua file.

Last edited by efortier : 10-30-14 at 12:34 PM. Reason: Added PS
  Reply With Quote
10-30-14, 12:58 PM   #2
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Give your button a name (second argument of CreateFrame) and then use CLICK ButtonName:LeftButton as the name field of your Binding element in bindings.xml.

http://wowpedia.org/Creating_key_bindings
http://wowpedia.org/API_SetBinding
  Reply With Quote
11-04-14, 02:16 PM   #3
efortier
A Defias Bandit
Join Date: Oct 2014
Posts: 2
Worked flawlessly. Thanks a bunch!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Problem binding key to a SecureActionButtonTemplate button


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