Is it possible to implement a long-press for the fab that shows small buttons with labels on top of the fab without additional components?
If not how to implement it with additional components but the same visual result?
My current FAB looks like this: https://codeberg.org/pabloscloud/Overload/src/commit/eae4132fd66d58d9ee52fe51ed18eb5bc2cd9f53/app/src/main/java/cloud/pablos/overload/ui/tabs/home/HomeTabFab.kt
FloatingActionButton(
onClick = {
/* onClick - event */
},
modifier = Modifier
.padding(10.dp),
containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainer,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.padding(8.dp),
) {
Icon(
imageVector = Icons.Default.PlayArrow
contentDescription = stringResource(id = R.string.edit),
modifier = Modifier.padding(8.dp, 0.dp, 0.dp, 0.dp),
)
TextView(
text = stringResource(id = R.string.start),
modifier = Modifier.padding(8.dp, 0.dp, 8.dp, 0.dp),
)
}
}
I tried using other components instead of a FAB but couldn't get it to act and look the same.

You can build this in 3 ways as i can think of probably there are other ways too.
You can use
InteractionSourceto determine how long fab is pressed withcollectLatestbecause need to trigger click on fast clicks and cancel previous action.Second option is to copy-paste source code and use it with
Surfacethat doesn't have onClick param and addModifer.combinedClickable.Third option is to create a
Modifier.pointerInput(){}withPointerEventPass.Initialto get long click event before FloatingActionButton or Button.I will post first option because this one is easier than copy-paste and modify solution.
You can also apply this solution to
Buttonsince it also takesInteractionSourceas param.