Thread Tools Display Modes
02-29-16, 03:10 PM   #1
ceylina
A Wyrmkin Dreamwalker
Join Date: Oct 2014
Posts: 50
Passing keypress to variable for pitbull luatext

I am wondering if it is possible to pass a keypress to pitbull unit frame's luatext.

I wrote a simple script to create a hidden frame and output the key pressed or just a string as a notification. I put in the print so I could validate it working which it does while allowing keyboard functions to not get locked. I only care about key down events as this is just every time the key is pressed, not released

I created a new text in the layout editor for pitbull and dumped the above code in. It works but now I am wondering how do I take it one step further and pass the variable for "key" to something that could be output to the text in pitbull instead of printing to the chatframe?

Also wondering about the best way to go about throttling text in case of pressing the key multiple times quickly like in a combat situation with a rotation. So it only reporting the output every say 2 seconds with a delay before initially starting.

Something like this (saw monkdev's simplified frame code and used it):
Code:
local keyPress  = KeyPressFrame or CreateFrame("Frame", "KeyPressFrame", UIParent)
local function TestPrint(self, key)
if key == "X" and UnitAffectingCombat('player') then
   print(self:GetName(), key)
end
end
keyPress:SetScript("OnKeyDown", TestPrint)
keyPress:SetPropagateKeyboardInput(true)


I basically want the functionality of something like IsShiftKeyDown where I can pass a notice every time a key is pressed.

Is a hidden frame even the best option? I can't hook into the player fame made by pitbull and enable keyboard input or it locks out all keyboard input.

I'm sure I will find something but there isn't a lot of documentation on this and hardly any examples of how to go about this. seems way too much effort for something that should be easy to do in game.

Last edited by ceylina : 02-29-16 at 03:36 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Passing keypress to variable for pitbull luatext


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