Jump to content
Toggle menu
  • 17.3K articles
  • 8.2K files
  • 5 users
  • 280.7K edits
WoW Classic Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

HOWTO: Use Bindings.xml to create key bindings for your AddOn

From WoW Classic Wiki

Example:

bindings.xml

<Bindings>
  <Binding name="DOSTUFF" description="Default description" header="MYDOSTUFF">
    DoSomething();
  </Binding>
  <Binding name="DOOTHERSTUFF" description="Other default description" runOnUp="true">
    if ( keystate == "down" ) then
      DoSomethingElse();
    else
      DoSomethingYetDifferent();
    end
  </Binding>
  <Binding name="DOMORESTUFF" description="Yet another default description">
    DoOneThing();
  </Binding>
</Bindings>


dostuff.lua

-- Binding Variables
BINDING_HEADER_MYDOSTUFF = "The header";
BINDING_NAME_DOSTUFF = "a name";
BINDING_NAME_DOOTHERSTUFF = "another name";
BINDING_NAME_DOMORESTUFF = "yet another name";


Notes

  • The Binding attribute runOnUp="true" is needed to use the keystate variable; unneeded otherwise.
  • A binding with no keystate will fire on key down.
  • WoW starts a new header when it finds a header="MYDOSTUFF" in a binding definition.
    You can not "hook into" a previous header using this way.
  • WoW tries to look for a lua variable BINDING_HEADER_MYDOSTUFF if you use header="MYDOSTUFF".
    If it can not find that, your binding will end up with the previous header.
  • if you use name="DOSTUFF" then WoW tries to look for a lua variable
    named BINDING_NAME_DOSTUFF. If that is not found, it uses description.
    If description is not present, it uses the name.
    This last case will look ugly.


The juggling about with LUA variable names is to make it possible to localize your addon. See HOWTO: Localize an AddOn for standard localization practices.