ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   number of key bindings (https://www.esoui.com/forums/showthread.php?t=1688)

hulksmash 05/31/14 05:14 PM

number of key bindings
 
So everyone wants key bindings on my SWAPS Addon and more presets... In theory I want to make an unlimited set of presets which can be attached to a key binding of your choice. I got everything done except the key bindings. Its looking really awesome.

I have yet to really play with key bindings but this should be possible correct? Or am I going to run into a problem with a fixed amount?

katkat42 05/31/14 11:31 PM

Quote:

Originally Posted by hulksmash (Post 8869)
So everyone wants key bindings on my SWAPS Addon and more presets... In theory I want to make an unlimited set of presets which can be attached to a key binding of your choice. I got everything done except the key bindings. Its looking really awesome.

I have yet to really play with key bindings but this should be possible correct? Or am I going to run into a problem with a fixed amount?

Well, if nothing else, you're going to run into a problem with a fixed number of keys on the keyboard! :D

But no, I'm afraid this probably won't be possible -- when you define new keybindings, you have to do them in XML, and I don't know of a way to do it programmatically or dynamically. So you're limited to the keybinds you define in advance. Am I explaining this clearly?

stjobe 06/01/14 12:00 AM

I just did my first addon keybindings yesterday (for OmniStats), and it's pretty well laid out in AddOn Quick Questions on the wiki how to do it.

Unless there's other ways of doing it, katkat42 is correct in that you have to define your keybindings in advance (in bindings.xml and bindings.lua).

hulksmash 06/01/14 07:49 AM

Quote:

Originally Posted by katkat42 (Post 8879)
But no, I'm afraid this probably won't be possible -- when you define new keybindings, you have to do them in XML, and I don't know of a way to do it programmatically or dynamically. So you're limited to the keybinds you define in advance. Am I explaining this clearly?


Yeah thats kind of what I was kind of grasping from the wiki. I guess to be clear with my question I wanted to make dynamic key bindings with lua and no xml. In my SWAPS addon, I made it so you can make an unlimited number of skill presets but everyone wanted key bindings to a preset. My idea was to set a keybinding as you make a skill preset. Which meant you can make any preset bound until you run out of keyboard keys.

So based on what you said, dynamic keybinding might not be possible.

zgrssd 08/06/14 10:02 AM

So dynamically defining Keybinds is not possible, I got that.

But what about dynamically assigning the keybind up/down callbacks? Anybody got an idea where I could find the list/table of Keybindings?
/zgoo _G has no obvious entry I could find.

Say, I make Keybinds 1-5 in XML but without any callback. Maybe I even tell them not to be shown by default (so they only show after I assigned a callback), if possible.
Then I dynamically assign the callbacks to each binding from code, till I run out of bindings or things to assign.

katkat42 08/06/14 04:11 PM

Quote:

Originally Posted by zgrssd (Post 11201)
So dynamically defining Keybinds is not possible, I got that.

But what about dynamically assigning the keybind up/down callbacks? Anybody got an idea where I could find the list/table of Keybindings?
/zgoo _G has no obvious entry I could find.

Say, I make Keybinds 1-5 in XML but without any callback. Maybe I even tell them not to be shown by default (so they only show after I assigned a callback), if possible.
Then I dynamically assign the callbacks to each binding from code, till I run out of bindings or things to assign.

How about this? You assign each keybinding a callback function, say, MyCallbacks.Keybind1() through 5(). In LUA code, you first define them to be empty functions:
Lua Code:
  1. function MyCallbacks.Keybind1() end

Later, you can re-define the functions, because lua treats functions like just another variable:
Lua Code:
  1. MyCallbacks["Keybind1"] = function() d("Hello World!") end

Does this seem like it would work?


All times are GMT -6. The time now is 07:55 PM.

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