-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Focus Events #578
Focus Events #578
Conversation
There's no point preventing the default from occurring here. Any web app trying to listen to these events will just be frustrated by it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great - I've approved but please don't forget to add the package aliases to your new events. Same goes for your other PRs. 👍
target match { | ||
case e: dom.Element if e.tagName == "WINDOW" => true | ||
case _ => false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cute. 😄
of the application if the game is being run from inside a web application (such as | ||
a Tyrian App or game site). In this scenario the `Canvas*` events will fire whenever | ||
the canvas loses or gains focus from the user clicking around the external parts | ||
of the site, and will also fire when the application loses or gains focus. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, just beware the docs are in flux...
|
||
/** The game canvas has lost focus | ||
*/ | ||
case object CanvasLostFocus extends GlobalEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't forget to add aliases to the package.scala file to help people import these:
val FrameTick: shared.events.FrameTick.type = shared.events.FrameTick |
This PR adds 4 new events to Indigo:
ApplicationGainedFocus
ApplicationLostFocus
CanvasGainedFocus
CanvasLostFocus
These new events close #513 and fire whenever the application or game canvas gain or lose focus. This can be useful for things like pausing a game whenever the user switches tabs, or taking an action if the user clicks off of the game canvas inside a web app