Thread Tools Display Modes
04/07/14, 02:05 PM   #1
tiomun
 
tiomun's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
Key Binding?

So I have a really nice control I created id like to add key binding options to the Controls > Keybindings interface, and also have them preset with defaults. Obviously from a saved variable, but the commands to do this have been hard to find. I searched here and the api docs a few times with no luck. I was wondering if anyone had any tips on this? I know at least one addon had options for keybinding, but I don't remember which one so it will take me a while to find a example to learn from.

Also is there a way to see if a key is held down?
  Reply With Quote
04/07/14, 02:39 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
http://wiki.esoui.com/AddOn_Quick_Qu...an_tie_into.3F
  Reply With Quote
04/07/14, 05:41 PM   #3
tiomun
 
tiomun's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
Excellent thank you
  Reply With Quote
04/08/14, 06:48 AM   #4
tiomun
 
tiomun's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
So having some issues with this.

bindings.xml
Code:
<Bindings>
	<Layer name="|cFF8C00Rive|r Mouse Mod">
		<Category name="General Options">
			<Action name="RMM_MOUSE_MOD_ENABLE">
				<Down>RMM_ToggleEnabled()</Down>
			</Action>
		</Category>
	</Layer>
</Bindings>
Bindings.lua
Lua Code:
  1. ZO_CreateStringId("SI_BINDING_NAME_RMM_MOUSE_MOD_ENABLE", "Toggle Mouse Mod on/off")

This part seems to work as far as adding options to the keybindings menu..

function in main lua file
Lua Code:
  1. function RMM_ToggleEnabled()
  2.     rmm_data.AddonEnabled = not rmm_data.AddonEnabled
  3.     if rmm_data.AddonEnabled == false then
  4.         d("Disabled " .. rmm_name)
  5.     else
  6.         d("Enabled " .. rmm_name)
  7.     end
  8. end

in txt file
Code:
RiveMouseMod.lua

lib/LibStub/LibStub.lua
lib/LibAddonMenu-1.0/LibAddonMenu-1.0.lua

bindings/bindings.xml
bindings/Bindings.lua
RiveMouseMod.xml
So the issue is, when I assign a key to bind it doesn't seem to fire the function in the main lua file...
Not sure why its not working. Even comparing it to other addons it looks fine, I think.

Also is there a way to set a default key to be bound?
  Reply With Quote
04/08/14, 02:57 PM   #5
tiomun
 
tiomun's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
Ok I figured it out.

Code:
<Bindings>
	<Layer name="|cFF8C00Rive|r Mouse Mod"> <--Must be "General"
		<Category name="General Options"><-- Must be to Addon name
			<Action name="RMM_MOUSE_MOD_ENABLE">
				<Down>RMM_ToggleEnabled()</Down>
			</Action>
		</Category>
	</Layer>
</Bindings>
So with the corrections

Code:
<Bindings>
	<Layer name="General">
		<Category name="|cFF8C00Rive|r Mouse Mod">
			<Action name="RMM_MOUSE_MOD_ENABLE">
				<Down>RMM_ToggleEnabled()</Down>
			</Action>
		</Category>
	</Layer>
</Bindings>
Which stinks! It looked cool having its own heading!
  Reply With Quote
04/12/14, 08:52 AM   #6
tiomun
 
tiomun's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
Still Need Default Key Bind help!!!

So I have created a really nice bag interface. and the above keybinding settings work well. However, there is a conflict between opening the default inventory, and opening my inventory.



The issue is, the default inventory is bound to B and I. If the user only binds B to my addon and hits I the default inventory still opens and steals back its children. This is avoidable if both B and I are bound to my addon. It would also improve the ease of use for my addon. I always like to reduce the amount of user configuration required for my projects.

I need to find how to set my addon to have default keys bound to it. I do not want to use the xml onKeyDoan method listed here http://wiki.esoui.com/AddOn_Quick_Qu...an_tie_into.3F since it does not allow for a user to change the keys to open the interface. pluss I havnt been able to get it to not make the rest of the game unresponsive (which I believe is the point when a tlc is open).

I have been through zgoo and the wikki many times now, and not found anything that would indicate a means of defining a default key for a control. I have been trying to get this working for the majority of the last week without any success.

Any help would be greatly appreciated.
  Reply With Quote
04/12/14, 09:32 AM   #7
Halja
 
Halja's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 111
You don't need to use the <OnKeyDown> or <OnKeyUp> events suggested in the Wiki. In fact, I would leave the hardcoded key press out all together. Let the user pick. The layer and category in the bindings.xml is were your custom key bind can be user set in the control menu of the game.


--halja

Last edited by Halja : 04/12/14 at 09:45 AM.
  Reply With Quote
04/12/14, 09:49 AM   #8
tiomun
 
tiomun's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
Originally Posted by Halja View Post
You don't need to use the <OnKeyDown> or <OnKeyUp> events suggested in the Wiki. In fact, I would leave the hardcoded key press out all together. Let the user pick. The layer and category in the bindings.xml it were your custom key bind can be user set in the control menu of the game.

--halja
I do have it setup that way, but id still like to define a default key for the option at least initially, to avoid the opening of the old inventory unless the user changes it back. All in all when I'm done this addon will overide most of the games ui and require many key bindings to be changed. There must be a way to set a key with the

ZO_CreateStringId("SI_BINDING_NAME", "") or something similar
  Reply With Quote
04/12/14, 09:52 AM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Specifying Down/Up are for if you want something different to happen with each one. If you don't, you don't need it. (Or you can just pick one, whatever.)

From the API list in the wiki:
CreateDefaultActionBind(string actionName, KeyCode key, KeyCode modifier1, KeyCode modifier2, KeyCode modifier3, KeyCode modifier4)
  Reply With Quote
04/12/14, 10:13 AM   #10
Halja
 
Halja's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 111
There also is one to change them but I have not used it.

BindKeyToAction protected (luaindex layerIndex, luaindex categoryIndex, luaindex actionIndex, luaindex bindingIndex, KeyCode key, KeyCode modifier1, KeyCode modifier2, KeyCode modifier3, KeyCode modifier4)

It references more the bindings.xml structure than the actions name.
  Reply With Quote
04/12/14, 09:09 PM   #11
tiomun
 
tiomun's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
Originally Posted by Seerah View Post
Specifying Down/Up are for if you want something different to happen with each one. If you don't, you don't need it. (Or you can just pick one, whatever.)

From the API list in the wiki:
CreateDefaultActionBind(string actionName, KeyCode key, KeyCode modifier1, KeyCode modifier2, KeyCode modifier3, KeyCode modifier4)
I did see CreateDefaultActionBind but I wasn't sure if it meant a action action or a event. in the couse of some of my trial and error I have gotten my comp to crash a few times so I am a bit hesitant to be as aggressive with my guess work.

Thank you very much. It looks like what I was in need of.
  Reply With Quote
04/12/14, 09:39 PM   #12
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Yeah... the ESO client seems to be a little... delicate. I've crashed it on several occasions. Most recently was this afternoon. I was trying to remember if tonumber() would work to strip a % from a number string. I put d(tonumber("13%)) into the chat, but, as you can see, forgot the closing quotes. Client crashed.
  Reply With Quote
04/13/14, 10:00 PM   #13
Daedros Endus
Join Date: Apr 2014
Posts: 1
I've been trying to create a keybinding, but I'm having issues getting it to show up in the keybinding menu. I even switched Layer to general like you said you had to do.

This is my xml:
Code:
<Bindings>
  <Layer name="General">
    <Category name="Custom Bind">
      <Action name="MAGIC">
        <Down>MagicStart()</Down>
        <Up>MagicStop()</Up>
      </Action>
    </Category>
  </Layer>
</Bindings>
This is the binding part of my lua:
Code:
ZO_CreateStringId("SI_BINDING_NAME_MAGIC", "magic")

EDIT: Bahahaha, I wasn't including them in my txt file....wow. Okay.

Anyway, I'd just like to thank everyone who has contributed to this thread. It's been helpful

Last edited by Daedros Endus : 04/13/14 at 10:13 PM.
  Reply With Quote
04/13/14, 10:49 PM   #14
Halja
 
Halja's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 111
Daedros Endus,

Switch your layer name for the international string variable.

Code:
<Bindings>
  <Layer name="SI_KEYBINDINGS_LAYER_GENERAL">
    <Category name="Custom Bind">
      <Action name="MAGIC">
        <Down>MagicStart()</Down>
        <Up>MagicStop()</Up>
      </Action>
    </Category>
  </Layer>
</Bindings>
That way your key bind will still work if the end-user is playing in French or German. There is also one for the Category. That is "SI_KEYBINDINGS_CATEGORY_USER_INTERFACE".
-Cheers
  Reply With Quote
04/14/14, 03:55 AM   #15
Etupa
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 8
Originally Posted by Halja View Post
Daedros Endus,

Switch your layer name for the international string variable.

Code:
<Bindings>
  <Layer name="SI_KEYBINDINGS_LAYER_GENERAL">
    <Category name="Custom Bind">
      <Action name="MAGIC">
        <Down>MagicStart()</Down>
        <Up>MagicStop()</Up>
      </Action>
    </Category>
  </Layer>
</Bindings>
That way your key bind will still work if the end-user is playing in French or German. There is also one for the Category. That is "SI_KEYBINDINGS_CATEGORY_USER_INTERFACE".
-Cheers
Damn ! thanks, lost my night on this ; ; ... I'm french so you can imagine my issue with those bindings.
  Reply With Quote
04/14/14, 11:41 AM   #16
Halja
 
Halja's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 111
np,

It tripped me up for a bit too. I kept bugging me it was working in English but not the other languages. Then it hit me as I was testing in German and noticed the text was changing for the titles and categories on the key-bind game menu. ZOS was using the xml attribute for the text.
Switching back and forth I saw:
  • "General"
  • "Allgemein"
  • "Général"
When I changed the bindings file to that language's "General" it worked for it. Then I just had to locate in the "SI_" table the localization string ZOS was using. Luckily, their names matched their function.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Key Binding?

Thread Tools
Display Modes

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