-
-
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
Mouse and Pointer Events #577
Conversation
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.
Broadly looks good. Going to have another look with fresh eyes.
I'm mostly concerned about the pointerType == PointerType.Mouse
filters. Another person was last working on this stuff and I'd been convinced that we should be moving to Pointer events rather than mouse since they were more broadly applicable and allowed us to support additional input types. This looks like we're filtering them out again, but I could be wrong, what's the deal?
MouseButton.fromOrdinalOpt(e.button).foreach { button => | ||
globalEventStream.pushGlobalEvent(MouseEvent.MouseDown(position, button)) | ||
|
||
if pointerType == PointerType.Mouse then { |
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.
I'm not sure we want that do we? I was under the impression that pointer events were also used for things like touch input?
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.
Yes they are, but we should really only fire things like MouseDown
if the pointer is actually a mouse. To be honest this is a deviation from the browser, which will fire a MouseDown
even if what actually occured was a touch event. Happy to keep the more standard browser behaviour of course, I personally feel this is more 'correct', but there's an argument I think for both approaches
indigo/indigo/src/main/scala/indigo/platform/events/WorldEvents.scala
Outdated
Show resolved
Hide resolved
There's definitely an argument to be had here for removing mouse events altogether, especially as |
A lot more properties have been added to the MouseEvent and PointerEvent objects to bring them in line with most of the JS equivalents. This includes things like special keys being down at the time of the event, and which buttons were down at the time of the event, as well as the type of pointer event received.
6edb94f
to
02ac3ca
Compare
It was removed accidentally in a rebase
Right, I'm with you now, thanks for the explanation. 👍 |
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.
LGTM, thanks @hobnob!
This is a breaking change, and I'm not sure I'm happy about it, so a second (or third) pair of eyes would be very welcome.
This change adds a majority of the properties found in both Mouse Events and Pointer Events. The upshot is that in doing so a simple
Click(position)
match now becomesClick(position, _, _, _, _, _, _, _)
, however we now have a wealth of new information about the event itself. some key changes are:Key Down Properties
Various helper properties (
isAltKeyDown
etc.) to check if a key was held down during the event. The difference here compared to, say, keeping a track of key up/down events within Indigo, is that if the button is held down outside of the scope of the game (such as in another window) this property will still be correct, whereas Indigo will think the button is not held down.Buttons Properties
The
buttons
proeprty was previously just onPointer
events, but is also available for theMouse
. As such, this property has now been moved to theMouse
event and updated to be aBatch
ofMouseButton
Mouse Enter/Leave
We already have a Pointer Enter/Leave - we now have the same for the mouse, which fixes #512
Tilting, Twisting, and Preassure
Pointer events have been updated with Tilt X/Y, Twist, and Preassure properties. More details on these can be found on the MDN docs. The main change from the docs here is that Twist and Tilt properties are in
Radian
s not degrees.Limited Firing of Events
Previously we fired mouse events every time we registered a pointer event. We now only do this if the pointer type is
Mouse
.