Hi All, I'm working on an JetpackCompose implemen...
# compose
t
Hi All, I'm working on an JetpackCompose implementation showing a list of Android Slices or just think about UI elements containing clickable items/components where the functionality or detailed Ui design is kind of a black box to me. Lets call this implementation a "Slices component" which is part of a more complex UI screen. My UI requirements request that this Slices component should now start special functionality on a long press. Therefore I was going to put e.g. a "@Composable Box" above the whole content which would handle the longpress. This Box look like the following: val longPressHandler = getKoin().getOrNull<LongPressHandler>(qualifier("LongPressHandler")) Box( modifier = Modifier .pointerInput(Unit) { detectTapGestures( onLongPress = { longPressHandler?.triggerLongPress() } ) } .fillMaxSize() ) /* * The ViewModel listens to this sharedflow and calls some functionality on it. */ class LongPressHandler { private val _longPressSharedFlow = MutableSharedFlow<Boolean>() val longPressSharedFlow = _longPressSharedFlow.asSharedFlow() fun triggerLongPress() { CoroutineScope(Main) .launch { _longPressSharedFlow.emit(true) } } } /** * Dependency injection module for this Class. */ val longPressHandlerModule = module { single(named("LongPressHandler")) { LongPressHandler() } } The longPress handling works as expected but now I have blocked(broke) all the clicks and other touch events for my parent or nested UI elements (the slices). How to achieve to only handle longPresses on the Box (FYI: doens't has to be a @Composable Box) but let all other click/touch events be handled by the underlaying Ui structure? How can parent or nested objects in Compose intercept the other click/touch events except the long presses? Help or hints are highly appreciated.