Skip to content
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

Implement stage.mouseLock and MouseEvent.movement properties #2702

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

ShaharMS
Copy link
Contributor

Mouse locking is already implemented in lime. This this pull requests implements mouse locking similarly to flash, as in:

  • Locking is only available in desktop targets and only when in full screen
    • On non-desktop targets, the mouseLock property is not available
    • When not in full-screen, setting mouseLock to true throws IllegalOperationError("Property can not be set in non full screen mode.");
  • When the mouse is locked MouseEvent's stageX/Y and localX/Y are equal to 0, and movementX/Y reports differences between previous and current mouse position.
  • Locking is temporarily disabled when the window loses focus, or exits fullscreen
    • When re-entering both of the states above, mouse locking is re-enabled

Implementation details:

under the hood, there's a less sensitive mouseLock property named __mouseLock. It is not changed when the user forces mouse unlocking, and is used for when the user temporarily disables mouse locking using one of the methods above. It is not used when retrieving stage.mouseLock, so it is possible that stage.mouseLock gets changed with user interaction, when the developer explicitly set it to true. The only property that the developer has full control of is __mouseLock, and it is the property deciding when to re-enable window.mouseLock.

Mouse events switch to reporting movement based coordinates only when the mouse is visually locked, so setting stage.mouseLock to true and receiving non-0 stageX property is possible, for example, but, this only happens when mouse locking is temporarily off. We know mouse locking is temporarily off when __mouseLock && !window.mouseLock

mouse movement details are retrieved from __onLimeMouseMoveRelative event listener

@ShaharMS
Copy link
Contributor Author

Closes #1724

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant