ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Any way to find keybinds? (https://www.esoui.com/forums/showthread.php?t=2494)

SnowmanDK 12/04/14 08:17 AM

Any way to find keybinds?
 
Hi
As I have set up so you can add keybindings to Bank Manger Revived, then I wonder if it's possible to detect what keys have been set from inside the addon.

Example:
Transfer Gold F2

I would like to be able to add that key (F2) to the tooltip on the button for the gold transfer, so it would read something like:
Gold (F2)

Is this possible?
I did try and go through the API but can't seem to find anything...

Garkin 12/04/14 12:12 PM

It should be something like this:

Lua Code:
  1. local actionName = "BMR_GOLD_TRANSFER"
  2. local layerIndex, categoryIndex, actionIndex = GetActionIndicesFromName(actionName)
  3. local bindingIndex = 1 --1 or 2, primary or secondary binding
  4.  
  5. local keyCode, mod1, mod2, mod3, mod4 = GetActionBindingInfo(layerIndex, categoryIndex, actionIndex, bindingIndex)
  6.  
  7. --I assume that you use bindings without modifier keys (ALT, CTRL, SHIFT, COMMAND), so this example uses just keyCode
  8. d(zo_strformat("Action |cFFFFFF<<1>>|r is bound to |cFFFFFF<<2>>|r.", actionName, GetKeyName(keyCode)))

Or you can use a bit more complex function defined in the UI which prints also modifier keys (I'd prefer this method):
Lua Code:
  1. local actionName = "BMR_GOLD_TRANSFER"
  2.  
  3. --KEYBIND_TEXT_OPTIONS_ABBREVIATED_NAME = 1
  4. --KEYBIND_TEXT_OPTIONS_FULL_NAME = 2
  5. --KEYBIND_TEXT_OPTIONS_FULL_NAME_SEPARATE_MODS = 3
  6. local textOptions = KEYBIND_TEXT_OPTIONS_ABBREVIATED_NAME
  7.  
  8. --KEYBIND_TEXTURE_OPTIONS_NONE = 1
  9. --KEYBIND_TEXTURE_OPTIONS_EMBED_MARKUP = 2
  10. local textureOptions = KEYBIND_TEXTURE_OPTIONS_NONE
  11.  
  12. local bindingIndex = 1  --1 or 2, primary or secondary binding
  13.  
  14. local bindingString = ZO_Keybindings_GetBindingStringFromAction(actionName, textOptions, textureOptions, bindingIndex)
  15.  
  16. d(zo_strformat("Action |cFFFFFF<<1>>|r is bound to |cFFFFFF<<2>>|r.", actionName, bindingString))

SnowmanDK 12/06/14 04:43 PM

Thanks, didn't know I can use modifiers. I guess they are pretty rare, or at least very limited :)


All times are GMT -6. The time now is 12:48 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI