Implement stage.mouseLock
and MouseEvent.movement
properties
#2702
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Mouse locking is already implemented in lime. This this pull requests implements mouse locking similarly to flash, as in:
mouseLock
property is not availablemouseLock
totrue
throwsIllegalOperationError("Property can not be set in non full screen mode.");
MouseEvent
'sstageX/Y
andlocalX/Y
are equal to 0, andmovementX/Y
reports differences between previous and current mouse position.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 retrievingstage.mouseLock
, so it is possible thatstage.mouseLock
gets changed with user interaction, when the developer explicitly set it totrue
. The only property that the developer has full control of is__mouseLock
, and it is the property deciding when to re-enablewindow.mouseLock
.Mouse events switch to reporting movement based coordinates only when the mouse is visually locked, so setting
stage.mouseLock
totrue
and receiving non-0stageX
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