Reputation: 1
Click function works fine, when i need a other gestures like Double tap, long press ect. i cant perform these actions.
example of working 'SingleChoiceSegmentedButtonRow'
SingleChoiceSegmentedButtonRow {
optionsMain.forEach { (key, value) ->
SegmentedButton(
shape = SegmentedButtonDefaults.itemShape(
index = key,
count = optionsMain.size
),
onClick = {
if (selectedIndex != key) {
controller.navigate(value.second)
selectedIndex = key
}
},
selected = key == selectedIndex,
icon = {
CustomIcon(active = selectedIndex == key)
}
) {
Text(value.first.toString())
}
}
}
example gesture failure of 'SingleChoiceSegmentedButtonRow'
SingleChoiceSegmentedButtonRow {
optionsMain.forEach { (key, value) ->
SegmentedButton(
shape = SegmentedButtonDefaults.itemShape(
index = key,
count = optionsMain.size
),
onClick = {
if (selectedIndex != key) {
controller.navigate(value.second)
selectedIndex = key
}
},
selected = key == selectedIndex,
icon = {
CustomIconV2(active = selectedIndex == key)
},
modifier = Modifier.pointerInput(Unit){
detectTapGestures(
onLongPress = {
longClick++
toastMessage = "Long Press Succesful :)"
},
onDoubleTap ={
doubleTap++
toastMessage = "Double Tap Succesful :)"
}
)
}
) {
Text(value.first.toString())
}
}
}
When i long press in segmentedButtons (anywhere) toast text appear and doubleTap value increase. But nothing happens. Only working click event, other gestures dont react.
I try 'SingleChoiceSegmentedButtonRow' modifier gestures.
SingleChoiceSegmentedButtonRow (
modifier = Modifier
.fillMaxWidth()
.pointerInput(Unit){
detectTapGestures(
onLongPress = {
toastMessage = "Row Long Press"
}
)
}
){..}
result unchanged.
Upvotes: 0
Views: 20