View Single Post
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:	743
Size:	504.9 KB
ID:	128  

Last edited by Xrystal : 04/12/14 at 07:11 PM.
  Reply With Quote