Global Event Listeners?

78 views
Skip to first unread message

Will Maynard

unread,
Sep 21, 2015, 6:34:28 PM9/21/15
to Haxe
I'm trying to capture some keyboard input, but I'm not sure how I can go about it.

I would like to bind certain functions to key presses - e.g. [Esc] to cancel when on certain screens in my app.

I'm using HaxeUI, so as far as I know, I don't have a Flash stage I can use to do this.  Is there any way to hook the keys and do something with the presses?

Juraj Kirchheim

unread,
Sep 22, 2015, 1:14:02 AM9/22/15
to haxe...@googlegroups.com
This should be the close enough to a stage: http://haxeui.org/docs/api/haxe/ui/toolkit/core/DisplayObject.html#root

Best,
Juraj

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Ian Harrigan

unread,
Sep 22, 2015, 4:50:52 PM9/22/15
to Haxe
Yeah, "DisplayObject.root" would do it, and if you arent using mulitple roots, you could use "RootManager.instance.currentRoot", or if you are "RootManager.instance.roots[n]". You do have access to the underlying sprite also, so you could also do "DisplayObject.sprite.stage", and a root is just a display object so "RootManager.instance.currentRoot.sprite.stage" would also work. :)

Or you could just use "openfl.Lib.current.stage"... heh heh.

Cheers,
Ian

Will Maynard

unread,
Sep 25, 2015, 3:21:41 PM9/25/15
to Haxe
Thanks, Ian!

openfl.Lib.current.stage did the trick.

I actually tried using Lib.current.stage (without openfl) last week with no success, but with how much the code has changed since then, I can't really compare what exactly is different now.

Sincerely,
Will
Reply all
Reply to author
Forward
0 new messages