Class PopupMenuKt

  • All Implemented Interfaces:

    
    public final class PopupMenuKt
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • PopupMenu

        @Composable() final static Unit PopupMenu(PopupMenuState popupMenuState, PopupMenuAppearance appearance, Function0<Unit> onDismiss)

        A popup menu that can be shown at a given offset. The menu items are shown in a row, and if there are more items than can fit in the row, a "more" button is shown. When the "more" button is clicked, the remaining items are shown in a dropdown. The menu will not exceed the bounds of its parent container

        Usage:

        var popupState by remember { mutableStateOf(PopupMenuState()) }
        
        Box(
            modifier =
            Modifier
                .fillMaxSize()
                .pointerInput(Unit) {
                    detectTapGestures(
                        onLongPress = { offset ->
                            val menuItems =
                                listOf(
                                    PopupMenuItemImpl("item 1") { action1() },
                                    PopupMenuItemImpl("item 2") { action2() },
                                    PopupMenuItemImpl("item 3") { action3() },
                                    PopupMenuItemImpl("item 4") { action4() }
                                )
                            popupState = PopupMenuState.shownAt(offset, menuItems)
                        }
                    )
                }
        ) {
            PopupMenu(
                popupStatus,
                dismiss = { popupStatus = PopupMenuState.hidden() }
            )
        }