Talk:Using bindings.xml to create key bindings for your addon
From WoWWiki
what is a binding?
Bindings.xml is to set up your own little section in the Key Bindings menu...so people can set up their keys to do stuff to your UI, like load it, or hide it, resize it, use one of it's 120 keys like Flexbar, open it's options, whatever...
It's what would add
WoWWiki Toggle WoWWiki [ not bound ] [ not bound ] Toggle Options [ not bound ] [ not bound ]
and it sets up exactly what happens when those buttons are pushed... --Astral 23:20, 27 Jun 2005 (EDT)
Here's a simple example for our "WoWWiki" AddOn (someday, right?)
in the Bindings.xml file is simply:
<Bindings> <Binding name="Toggle WoWWiki" header="WOWWIKIHEADER"> WoWWikiToggle(); </Binding> </Bindings>
See, all we have is is "Toggle WoWWiki" as a keybinding, the header="WOWWIKIHEADER" is a what you want a title above the binding, or the bindings that come after it to be. It's attached to the specific binding it's a part of (all it does is add a line above with the title). If our WoWWiki Addon did anything but show itself and hide, we could add another Binding (without the header) and give it another function...and if we had options and wanted each to be able to be done with a keypress, we should add more, with the set having it's own header
<pre>
<Bindings>
<Binding name="Toggle WoWWiki" header="WOWWIKIHEADER">
WoWWikiToggle();
</Binding>
<Binding name ="WoWWiki Up" header="WOWWIKIOPTSHEADER">
WoWWikiUp();
</Binding>
<Binding name ="WoWWiki Down">
WoWWikiDown();
</Binding>
<Binding name ="WoWWiki Left">
WoWWikiLeft();
</Binding>
<Binding name ="WoWWiki Right">
WoWWikiRight();
</Binding>
</Bindings>
(Use title of the program, or another section of the program's keybindings, such as Flexbar's first section, and then a whole new section for it's 120 button bindings...the first on it's list would the header, and the first button binding would have another header...consider it a part of that Binding) the
Inside each binding is the code that will be used when whatever key it gets bound to is pressed.
at the top of WoWWiki.lua file would be
BINDING_HEADER_JOTTERHEADER = "WoWWiki"; BINDING_HEADER_WOWWIKIOPTSHEADER = "WoWWiki Options";
which is what's sent as the header...
all this together shows, in the Key Bindings menu:
WoWWikki Toggle WoWWiki [ not bound ] [ not bound ] WoWWiki Options WoWWiki Up [ not bound ] [ not bound ] WoWWiki Down [ not bound ] [ not bound ] WoWWiki Left [ not bound ] [ not bound ] WoWWiki Right [ not bound ] [ not bound ]
Hope that helps --Astral 23:34, 27 Jun 2005 (EDT)