View Single Post
09-10-15, 07:21 AM   #2
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
You should definitely not use SetScript on frames that aren't your own, rather use HookScript, as it will append the script snippet with your code rather than replacing the original script function. Having that said, I don't think it's generally a good idea to hook shit onto the WorldFrame. You could just create your own invisible frame and have it propagate the keyboard input instead. Like this:

Lua Code:
  1. local f  = Test or CreateFrame("Frame", "Test", UIParent)
  2.  
  3. local function TestPrint(self, key)
  4.    print(self:GetName(), key)
  5. end
  6.  
  7. f:SetScript("OnKeyDown", TestPrint)
  8. f:SetPropagateKeyboardInput(true)

Also, get in the habit of localizing your functions.
__________________

Last edited by MunkDev : 09-10-15 at 07:24 AM.
  Reply With Quote