ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Key Binding? (https://www.esoui.com/forums/showthread.php?t=669)

tiomun 04/07/14 02:05 PM

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?

Seerah 04/07/14 02:39 PM

http://wiki.esoui.com/AddOn_Quick_Qu...an_tie_into.3F

tiomun 04/07/14 05:41 PM

Excellent thank you :)

tiomun 04/08/14 06:48 AM

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?

tiomun 04/08/14 02:57 PM

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!

tiomun 04/12/14 08:52 AM

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.

Halja 04/12/14 09:32 AM

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

tiomun 04/12/14 09:49 AM

Quote:

Originally Posted by Halja (Post 3968)
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

Seerah 04/12/14 09:52 AM

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)

Halja 04/12/14 10:13 AM

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.

tiomun 04/12/14 09:09 PM

Quote:

Originally Posted by Seerah (Post 3974)
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.

Seerah 04/12/14 09:39 PM

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.

Daedros Endus 04/13/14 10:00 PM

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 :)

Halja 04/13/14 10:49 PM

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

Etupa 04/14/14 03:55 AM

Quote:

Originally Posted by Halja (Post 4185)
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. :D

Halja 04/14/14 11:41 AM

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.:D


All times are GMT -6. The time now is 01:06 PM.

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