[CMP-7202] Introduce Unified Multiplatform Pointer Click Modifier#5570
Open
gagik894 wants to merge 3 commits intoJetBrains:masterfrom
Open
[CMP-7202] Introduce Unified Multiplatform Pointer Click Modifier#5570gagik894 wants to merge 3 commits intoJetBrains:masterfrom
gagik894 wants to merge 3 commits intoJetBrains:masterfrom
Conversation
…r clicks Introduce `onPointerClick` and `onPrimaryClick` modifiers to provide rich interaction metadata, including support for secondary/tertiary buttons and keyboard modifiers. - Add `PointerClickEvent` to encapsulate click position, button state, pointer type, and keyboard modifiers. - Implement `onPointerClick` modifier with support for custom press interaction triggers and visual indications. - Implement `onPrimaryClick` convenience modifier for standard primary interactions. - Ensure proper handling of touch slop, cancellation (e.g., during parent scrolling), and disabled states. - Support synthesized clicks via semantics for accessibility and keyboard navigation. - Include comprehensive test suite covering hardware buttons, modifiers, ripple lifecycles, and edge cases. ## Release Notes Experimental Compose Multiplatform input library providing advanced hardware-aware pointer click modifiers.
Introduce a multi-platform demo suite to showcase the `onPointerClick` modifier across Android and Desktop.
- Add `input:demo:shared` module containing a "PointerClick Laboratory" to test hardware-aware routing, ripple policies, and event logging.
- Add `input:demo:androidApp` providing a standard Android activity wrapper for the demo.
- Add `input:demo:desktopApp` providing a JVM-based desktop entry point for the demo.
- Implement `UsePointerClick` screen to demonstrate:
- Unified handling of Primary, Secondary, and Eraser inputs.
- Custom ripple trigger policies based on button state.
- Visual indication suppression (silent clicks).
- Real-time event inspection including pointer type, keyboard modifiers, and coordinates.
- Update `components/settings.gradle.kts` to include the new demo modules.
## Release Notes
N/A
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Introduces
Modifier.onPointerClickinorg.jetbrains.compose.components.input, providing a unified multiplatform API for handling pointer interactions (mouse buttons, stylus, keyboard modifiers) while preserving touch semantics.Resolves: CMP-7202
Problem
Modifier.clickabledoes not expose hardware details (button type, modifiers, pointer type).Solution
Modifier.onPointerClickprovides a single entry point for pointer-aware interactions via a structuredPointerClickEvent.Event Payload
position: Click position relative to componentbuttons: PointerButtons (nullable for accessibility/synthesized events)type: PointerType (Mouse, Touch, Stylus, etc.)keyboardModifiers: Shift/Ctrl/Alt/Meta stateisPrimaryAction,isSecondaryAction,isEraserImplementation
DelegatingNodeusing pointer + semantics nodesTesting