Michael Paus
09/12/2025, 2:24 PMpointerInput correctly in common code. I want to detect a right mouse click if the device is operated with a mouse. However, when I use the button property of the event, then I get a build time error for Android. Why? IntelliJ does not complain when I use this in common code.
if (event.button?.isSecondary ?: false) {...}
On Android:
Unresolved reference 'isSecondary'.
Unresolved reference 'button'.
The documentation says “Specifies the pointer button state of which was changed. It has value only when event’s type is PointerEventType.Press or PointerEventType.Release and when button is applicable (only for Mouse and Stylus events).” This tells me that button will just be null in case it is not applicable.
I tried this with Compose 1.9.0-rc02 and Kotlin 2.2.20 on a Mac.ephemient
09/12/2025, 3:36 PMbutton is not part of common expect class PointerEvent or android actual class PointerEvent, only skiko actual class PointerEvent (which is used on non-Android targets)ephemient
09/12/2025, 3:36 PMephemient
09/12/2025, 3:38 PMif (event.buttons.isPrimaryPressed)
insteadMichael Paus
09/12/2025, 5:53 PMMichael Paus
09/12/2025, 6:08 PM