Thread Tools Display Modes
05/31/14, 05:14 PM   #1
hulksmash
 
hulksmash's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 30
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?
  Reply With Quote
05/31/14, 11:31 PM   #2
katkat42
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 155
Originally Posted by hulksmash View Post
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!

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?
  Reply With Quote
06/01/14, 12:00 AM   #3
stjobe
 
stjobe's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
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).
  Reply With Quote
06/01/14, 07:49 AM   #4
hulksmash
 
hulksmash's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 30
Originally Posted by katkat42 View Post
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.
  Reply With Quote
08/06/14, 10:02 AM   #5
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
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.
  Reply With Quote
08/06/14, 04:11 PM   #6
katkat42
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 155
Originally Posted by zgrssd View Post
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?
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » number of key bindings


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off