View Single Post
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