WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   SetBinding issues (https://www.wowinterface.com/forums/showthread.php?t=57816)

doofus 02-13-20 02:07 AM

SetBinding issues
 
Hello.

I have used SetBinding to tie keystrokes to macros. These are saved in bindings-cache.wtf.

If I change the binding key of a macro, the old binding is still present in this file, and I cannot get rid of it, or know what other bindings this macro has. The only solution is to manually delete bindings-cache.wtf.

Is there an API I can use to delete all bindings present for a specific macro ?

Thanks

SDPhantom 02-13-20 06:02 PM

You can send nil as (or completely omitt) the second argument to SetBinding() to remove the key from all bindings.

I don't know if GetBinding() works on custom bindings. It might not.

doofus 02-16-20 03:52 AM

Thank you, however it is the opposite function I need,

1) delete all key-bindings for a specific macro without knowing how many bindings exit for that macro
2) delete all key-bindings for all macros

SDPhantom 02-17-20 05:11 PM

Quote:

Originally Posted by doofus (Post 335150)
Thank you, however it is the opposite function I need,

1) delete all key-bindings for a specific macro without knowing how many bindings exit for that macro
2) delete all key-bindings for all macros

Reiterating:
Quote:

Originally Posted by SDPhantom (Post 335137)
I don't know if GetBinding() works on custom bindings. It might not.

On another note, if you know the command string, you might try GetBindingKey(), but like the other function, I don't know if this works on custom bindings. If neither of them do, then you're out of luck. That's all the API has for iterating through permanent ones.

There is a series of functions for override bindings, but that's a completely different system.

doofus 09-05-20 07:02 AM

On a similar note, I have a few macros like

Macro : "BOB"
/cast [@mouseover] MySpell

and then
SetBinding("F1", "MACRO BOB");

Due to limited number of macros, is there a way to use SetBinding in a way similar to the pseudo-code below, so as to avoid creating a macro?

-- this does not work
SetBinding("F1", "/cast [@mouseover] MySpell");

SDPhantom 09-05-20 06:37 PM

Nope. The only way around it is to write addon code to create an ActionButton, then have the binding click it.

I'd probably use SetOverrideBinding*() so it doesn't clutter Bindings.wtf. The first argument to these functions is the binding's owner. This lets you manage bindings as a group. For example, you can use ClearOverrideBindings() to remove all bindings that are owned by a frame.
Lua Code:
  1. local Button=CreateFrame("Button","AddOnName_ButtonName",nil,"SecureActionButtonTemplate");
  2. Button:SetAttribute("type","macro");
  3. Button:SetAttribute("macrotext","/cast [@mouseover] MySpell");
  4. SetOverrideBindingClick(Button,"F1","AddOnName_ButtonName");

doofus 09-06-20 03:58 PM

OK that worked thanks.


All times are GMT -6. The time now is 09:46 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI