Thread Tools Display Modes
12/28/14, 11:07 PM   #1
pluginpatch
Join Date: Dec 2014
Posts: 2
OnKeyUp/OnKeyDown via Lua

I am a new user on these forums and dabbling a bit in eso addons.

I am having trouble getting the handlers OnKeyDown and OnKeyUp to work. I have mostly used this post:
http://www.esoui.com/forums/showthread.php?t=2318
as a reference.

I have the following

Code:
local wm = GetWindowManager()

local container = wm:CreateTopLevelWindow("Container")
container:SetDimensions(600,600)
container:SetAnchor(CENTER, GuiRoot, CENTER, 0, 0)
container:SetHidden(true)
container:SetKeyboardEnabled(true)

container.wheel = wm:CreateControl("$(parent)Wheel", container, CT_TEXTURE)
container.wheel:SetTexture("esoui/art/quickslots/quickslot_mapping_bg.dds")
container.wheel:SetAnchor(CENTER, container, CENTER, 0, 0)

local function EventKeyDown(self, key)
    container:SetHidden(false)
end
container:SetHandler("OnKeyDown", function(self,key,ctrl,alt,shift,command) EventKeyDown(self, key) end)
I used to have if statements to check for specific keys, but I was afraid they were messing me up.
When setting the texture SetHidden(true) I do see the texture, so it works, but I cannot make the key events work.
  Reply With Quote
12/29/14, 10:44 AM   #2
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
Originally Posted by pluginpatch View Post
When setting the texture SetHidden(true) I do see the texture, so it works, but I cannot make the key events work.
If you see the texture, doesn't that mean the key events are working? You're setting it to hidden initially and showing on (any) keypress.

One other note: you should name the root control something a little more specific than "Container". I'm not sure how it'd handle duplicate root window names, but it's best to avoid naming conflicts.
  Reply With Quote
12/29/14, 12:10 PM   #3
pluginpatch
Join Date: Dec 2014
Posts: 2
Ha, sorry, I meant the opposite. When setting the texture SetHidden(false) I do see the texture.

I will try renaming the control.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » OnKeyUp/OnKeyDown via Lua


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