WoW:API SetBinding: Difference between revisions
Jump to navigation
Jump to search
m (→Arguments) |
m (→Details: ... on second thought, there is an option to not store bindings on the server.) |
||
Line 18: | Line 18: | ||
== Example == | == Example == | ||
-- | -- Remove all bindings from the right mouse button. | ||
SetBinding("BUTTON2"); | SetBinding("BUTTON2"); | ||
-- | -- Restore the default binding for the right mouse button. | ||
SetBinding("BUTTON2","TURNORACTION"); | SetBinding("BUTTON2","TURNORACTION"); | ||
Line 28: | Line 28: | ||
* The Key Bindings UI will update immediately should this function succeed. However, bindings are not saved without an explicit {{api|SaveBindings}}() call. Unless saved, bindings will reset on next log-in / bindings load. | * The Key Bindings UI will update immediately should this function succeed. However, bindings are not saved without an explicit {{api|SaveBindings}}() call. Unless saved, bindings will reset on next log-in / bindings load. | ||
* A list of default FrameXML bindings.xml-defined actions is available: [[BindingID]]. | * A list of default FrameXML bindings.xml-defined actions is available: [[BindingID]]. | ||
* The Addon API doesn't know what the default binding is for any single action. You can set them all to their defaults by calling <code>{{api|LoadBindings}}(DEFAULT_BINDINGS)</code>; this is an all-or-nothing action. | |||
==See Also== | ==See Also== |
Revision as of 23:50, 14 March 2010
← WoW API < SetBinding
This function is protected, and cannot be called from insecure code while in in combat.
|
Alters the action performed by a binding.
ok = SetBinding("key"[, "command"[, mode]]);
Arguments
- key
- String - Any binding string accepted by World of Warcraft. For example: "ALT-CTRL-F", "SHIFT-T", "W", "BUTTON4".
- command
- String/nil - Any name attribute value of a Bindings.xml-defined binding, or an action command string. For example:
- "SITORSTAND" : a Bindings.xml-defined binding to toggle between sitting and standing
- "CLICK PlayerFrame:LeftButton" : Fire a left-click on the PlayerFrame.
- "SPELL Bloodrage" : Cast Bloodrage.
- "ITEM Hearthstone" : Use Template:Item
- "MACRO Foo" : Run a macro called "Foo"
- "MACRO 1" : Run a macro with index 1.
- mode
- Number - 1 if the binding should be saved to the currently loaded binding set (default), or 2 if to the alternative.
Returns
- ok
- Flag - 1 if the binding has been changed successfully, nil otherwise.
Example
-- Remove all bindings from the right mouse button. SetBinding("BUTTON2"); -- Restore the default binding for the right mouse button. SetBinding("BUTTON2","TURNORACTION");
Details
- There are two binding sets: per-account and per-character bindings; of which one may be presently loaded (LoadBindings). You may look up which one is currently loaded using GetCurrentBindingSet().
- A single binding can only be bound to a single command at a time, although multiple bindings may be bound to the same command. The Key Bindings UI will only show the first two bindings, but there is no limit to the number of keys that can be used for the same command.
- The Key Bindings UI will update immediately should this function succeed. However, bindings are not saved without an explicit SaveBindings() call. Unless saved, bindings will reset on next log-in / bindings load.
- A list of default FrameXML bindings.xml-defined actions is available: BindingID.
- The Addon API doesn't know what the default binding is for any single action. You can set them all to their defaults by calling
LoadBindings(DEFAULT_BINDINGS)
; this is an all-or-nothing action.