Thread Tools Display Modes
04/12/14, 07:05 PM   #1
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Custom Keybind Strip

Based on TheLabs query .. a quick break from gatherer to have a look as it would be great I'm sure if we could get those key bind strips working in our addons.

Here's the code I used to get it doing what it is currently doing and a screenshot of what it is showing. Not quite what I expected but hey .. it may have ignored my settings.

This code was exexute in the addon loaded event function. I deliberately made it global so I could see what happened. As you can see the keyLabel and nameLabel values didn't make a difference. Once I used the Set functions there was some difference but as the screenshot shows, key is not bound. So perhaps, this works alongside the keybind functionality to work fully. Neither the callback or onclicked handler worked, and no error reported.


EDIT: Correction. Just tested again and the callback function is what you use to handle the clicking of the button. The keybinding clearly has to be set up elsewhere.

EDIT 2 : Oh, and definitely can't forget to mention that this was all thanks to zgoo.


Just a little something to spark inspiration into our addons to make them feel part of the game.

Lua Code:
  1. testStrip = CreateTopLevelWindow("xmp_teststrip")
  2.     testStrip.Control1 = CreateControlFromVirtual("$(parent)_Control1",testStrip,"ZO_KeybindStripButtonTemplate")
  3.     testStrip.Control1:SetKeybind("SHIFT-H")
  4.     testStrip.Control1:SetText("SHHHHHH")
  5.     testStrip.Control1:SetCustomKeyText("Shift H")
  6.     testStrip.Control1:SetCallback(function(self) ChatMsg:AddMessage("SHHHHHH") end)
  7.     --testStrip.Control1.keyLabel:SetText("Q")
  8.     --testStrip.Control1.nameLabel:SetText("SHHHH")
  9.     testStrip.Control1:SetHandler("OnClicked", function(self,button) ChatMsg:SetMessage("SHHHHH") end)
  10.     testStrip:SetAnchor(CENTER)
  11.     testStrip:SetHidden(false)
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20140413_015810.jpg
Views:	730
Size:	504.9 KB
ID:	128  

Last edited by Xrystal : 04/12/14 at 07:11 PM.
  Reply With Quote
04/24/14, 09:52 AM   #2
Thenedus
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1
There is a nice function in KEYBIND_STRIP that takes care of all the details:

Code:
local stripDescriptor = {
  {
    alignment = KEYBIND_STRIP_ALIGN_RIGHT, // or _LEFT, _CENTER
    name = "Display name",
    keybind = "YOUR_KEYBIND_ACTION_NAME",
    callback = function(self) d("activated") end
  }
}
KEYBIND_STRIP:AddKeybindButtonGroup(stripDescriptor)
-- to remove it again
-- call with exactly the same descriptor or strange things will happen
KEYBIND_STRIP:RemoveKeybindButtonGroup(stripDescriptor)
The value for keybind must be defined for the SI_KEYBINDINGS_LAYER_USER_INTERFACE_SHORTCUTS layer.
The keybind overrides any general keybind as long the as button group is displayed. For example, I assigned "J" to the binding. When the keybind is displayed, "J" triggers the callback. Otherwise, "J" opens the journal.
  Reply With Quote
05/09/14, 03:00 PM   #3
DerVagabund
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 12
Hello,

I just tried this and if I set it to J, it does ignore my command and opens the quest journal.
  Reply With Quote

ESOUI » Developer Discussions » Tutorials & Other Helpful Info » Custom Keybind Strip


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