+ Reply to Thread
Results 1 to 3 of 3

Thread: Intercepting the escape and return keys?

  1. #1
    Wym
    Wym is offline
    Shadowlander
    Join Date
    Jun 2012
    Posts
    25

    Default Intercepting the escape and return keys?

    I'm almost embarassed to ask this question .. but i've been trying for quite a while now and just can't get this to work. I open a RiftWindow like this
    Code:
    Window=UI.CreateFrame("RiftWindow", "Messages", context)
    and want to close it when the user presses the escape button. So i tried to add key events to both the window, and its content window:
    Code:
    local content=window:GetContent()
    content:EventAttach(Event.UI.Input.Key.Down.Dive, function(handle, key)
    	print("c"); dump(key)
    end, "KeyDown", 999)
    window:EventAttach(Event.UI.Input.Key.Down.Dive, function(handle, key)
    	print("w"); dump(key)
    end, "KeyDown", 999)
    Then i make the window visible using
    Code:
    	latestEventWindow:SetVisible(true)
    	latestEventWindow:GetContent():SetKeyFocus(true)
    Now my first problem is: I get all key events, EXCEPT when i press escape. When i set the key focus to the content window, both events fire; when i set it to the window itself (remove the purple part), only the window event fires. The escape key seems to get consumed somehow (pressing escape doesn't open the system menu like it normally does), but i get no key event. Replacing the Down.Dive with Down, or Down.Bubble, or Type, doesn't change anything.

    Second problem: when i print the key, i always get an empty array. I don't seem to be able to find out which key it was no matter what i try.

    Are these bugs with the new event model? Should i use the old one? (I'd hate to). Or am i missing something important completele?

  2. #2
    Rift Chaser Ferather's Avatar
    Join Date
    Jun 2011
    Posts
    341

    Default

    Only thing I can think of is to some how make use of the RiftTextField key feature by making a RiftTextField then make the frame hidden take focus and to trigger something on escape press, If that makes any sense.

    In Super Meter I make the frame disappear on key up, dont know if any of that is of use.
    Last edited by Ferather; 08-31-2013 at 02:42 PM.

  3. #3
    Telaran
    Join Date
    Oct 2011
    Posts
    86

    Default Return

    Quote Originally Posted by Ferather View Post
    Only thing I can think of is to some how make use of the RiftTextField key feature by making a RiftTextField then make the frame hidden take focus and to trigger something on escape press, If that makes any sense.

    In Super Meter I make the frame disappear on key up, dont know if any of that is of use.
    I ran some tests and you can capture the RETURN key, as well as any key on the keyboard except it seems the ESC and the PRT SCR key. Zorba had mentioned that the ESC may possibly become a global function in the future though.
    Author of RiftHud, RiftActionbarCooldowns, RunecraftHelper, RiftHealer, and RiftMenuXtra. Can be found at RiftUI and Curse.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts