Comments (3)
Compose should generate non-zero/unique change ID values similar to the behavior on Android.
Why? Could you please explain your use case? It doesn't seem as a bug for me.
This ID is unique in case of touch but not for mouse even on Android (to test this try to drag with bluetooth mouse connected to real device).
from compose-multiplatform.
Why? Could you please explain your use case? It doesn't seem as a bug for me.
Thank you for the additional information. To clarify, I'm writing a 3rd party client application that needs to support three button activation options:
- Standard press/release: Does not react to drag events
- Single drag-press: The button will only fire one click event per drag event that touches the button
- Multi drag-press: The button will fire click events every time a drag event touches the button
The parent Box composable sets up a MutableStateFlow for the PointerInputChange onDrag ID's Long value that is passed to button composables within the Box that subscribe to the flow. In the case of single drag-press, the Button remembers the last ID to limit clicks to one per PointerInputChange ID.
I originally initialized the ID flow with a value of 0 which worked beautifully on Android and compose. Migrating to multiplatform, PointerInputChange always emitting a matching value of 0 meant buttons set to single drag-press always ignored drag events on desktop.
I've worked around the behavior by changing the ID flow to support null values, and added an additional drag end event handler to emit a null value to the MutableStateFlow. It works, although altering the flows to allow null values feels like an anti-pattern.
This ID is unique in case of touch but not for mouse even on Android (to test this try to drag with bluetooth mouse connected to real device).
The PointerInputChange documentation doesn't mention that IDs are unique for touch events only, which is why I believed this was a defect.
However, it sounds like this is expected behavior, and I suspect my "single drag-press" use case may be rare.
from compose-multiplatform.
I see, thanks for clarification.
From that mentioned docs:
id
The unique id of the pointer associated with thisPointerInputChange
.
"unique id of the pointer" - so mouse is a single pointer with id 0. Clicking the button doesn't create a new pointer, but starting the touch does. So, I believe that current behaviour matches documentation.
Closing as it's expected behaviour and you already found workaround.
from compose-multiplatform.
Related Issues (20)
- is compose multiplatform for web wasmJs support routing ? HOT 3
- UI Preview does not work inside Android Studio HOT 1
- SelectionContainer crashed when right click space area
- (iOS) Selection Container shows keyboard while selecting text
- `isSystemInDarkTheme()` not causing recomposition when using `UINavigationController` as wrapper on compose `UIViewController` HOT 5
- ModalBottomSheet no appearance animation in skiko targets HOT 2
- App crashes when launched on x86_64 iOS simulator after migrated to Kotlin 2.0 HOT 2
- MLKit linkPodDebugFrameworkIosArm64 FAILED HOT 1
- On the Web platform, VectorPainter cannot get the correct size and draw content when running inside other Painters
- Screen flickering On WIndows Desktop HOT 1
- [iOS] org.jetbrains.compose.resources.MissingResourceException when running tests HOT 5
- LazyVerticalStaggeredGrid two columns with five items with difference horizontalArrangement, the last item sometimes on the left, sometimes on the right HOT 4
- Compose Desktop Gradle Plugin should honor JVM `toolchain`
- graphicsLayer render resolution slower towards bottom of screen
- (Desktop) minimumInteractiveComponentSize + size/width/height Modifier leads to inconsistent placement HOT 3
- iOS. Animation crashes with OOM inside bottom sheet
- TextField error: kotlin.IllegalStateException: ComposeScene is closed HOT 3
- NPE in UndecoratedWindowResizer.desktop.kt in java.awt.PointerInfo.getLocation()
- Deep Linking Support - iOS HOT 5
- Compose Multiplatform and Jetpack Compose method signatures are inconsistent. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compose-multiplatform.