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

Fixed a case where [event.modifiersEx] does not provide info about the pressed mouse button (AWT). #181

Merged
merged 3 commits into from
Feb 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,25 @@ private fun ComposeScene.onMouseWheelEvent(
)
}


@OptIn(ExperimentalComposeUiApi::class)
private val MouseEvent.buttons get() = PointerButtons(
isPrimaryPressed = (modifiersEx and MouseEvent.BUTTON1_DOWN_MASK) != 0 && !isMacOsCtrlClick,
isSecondaryPressed = (modifiersEx and MouseEvent.BUTTON3_DOWN_MASK) != 0 || isMacOsCtrlClick,
isTertiaryPressed = (modifiersEx and MouseEvent.BUTTON2_DOWN_MASK) != 0,
isBackPressed = (modifiersEx and MouseEvent.getMaskForButton(4)) != 0,
isForwardPressed = (modifiersEx and MouseEvent.getMaskForButton(5)) != 0,
// We should check [event.button] because of case where [event.modifiersEx] does not provide
// info about the pressed mouse button when using touchpad on MacOS 12 (AWT only).
// When the [Tap to click] feature is activated on Mac OS 12, half of all clicks are not
// handled because [event.modifiersEx] may not provide info about the pressed mouse button.
isPrimaryPressed = ((modifiersEx and MouseEvent.BUTTON1_DOWN_MASK) != 0
Rsedaikin marked this conversation as resolved.
Show resolved Hide resolved
|| (id == MouseEvent.MOUSE_PRESSED && button == MouseEvent.BUTTON1))
&& !isMacOsCtrlClick,
isSecondaryPressed = (modifiersEx and MouseEvent.BUTTON3_DOWN_MASK) != 0
|| (id == MouseEvent.MOUSE_PRESSED && button == MouseEvent.BUTTON3)
|| isMacOsCtrlClick,
isTertiaryPressed = (modifiersEx and MouseEvent.BUTTON2_DOWN_MASK) != 0
|| (id == MouseEvent.MOUSE_PRESSED && button == MouseEvent.BUTTON2),
isBackPressed = (modifiersEx and MouseEvent.getMaskForButton(4)) != 0
|| (id == MouseEvent.MOUSE_PRESSED && button == 4),
isForwardPressed = (modifiersEx and MouseEvent.getMaskForButton(5)) != 0
|| (id == MouseEvent.MOUSE_PRESSED && button == 5),
)

@OptIn(ExperimentalComposeUiApi::class)
Expand Down