MenuScope



Receiver scope which is used by Menu.setContent, MenuBarScope.Menu, Tray

Summary

Public functions

Unit
@Composable
CheckboxItem(
    text: String,
    checked: Boolean,
    icon: Painter?,
    enabled: Boolean,
    mnemonic: Char?,
    shortcut: KeyShortcut?,
    onCheckedChange: (Boolean) -> Unit
)

Adds item with checkbox to the menu

android
Unit
@Composable
Item(
    text: String,
    icon: Painter?,
    enabled: Boolean,
    mnemonic: Char?,
    shortcut: KeyShortcut?,
    onClick: () -> Unit
)

Adds item to the menu

android
Unit
@Composable
Menu(
    text: String,
    enabled: Boolean,
    mnemonic: Char?,
    content: @Composable MenuScope.() -> Unit
)

Adds sub menu to the menu

android
Unit
@Composable
RadioButtonItem(
    text: String,
    selected: Boolean,
    icon: Painter?,
    enabled: Boolean,
    mnemonic: Char?,
    shortcut: KeyShortcut?,
    onClick: () -> Unit
)

Adds item with radio button to the menu

android
Unit

Adds separator to the menu

android

Public functions

CheckboxItem

@Composable
fun CheckboxItem(
    text: String,
    checked: Boolean,
    icon: Painter? = null,
    enabled: Boolean = true,
    mnemonic: Char? = null,
    shortcut: KeyShortcut? = null,
    onCheckedChange: (Boolean) -> Unit
): Unit

Adds item with checkbox to the menu

Parameters
text: String

text of the item that will be shown in the menu

checked: Boolean

whether checkbox is checked or unchecked

icon: Painter? = null

icon of the item

enabled: Boolean = true

is this item item can be chosen

mnemonic: Char? = null

character that corresponds to some key on the keyboard. When this key will be pressed - onCheckedChange will be triggered. If the character is found within the item's text, the first occurrence of it will be underlined.

shortcut: KeyShortcut? = null

key combination which triggers onCheckedChange action without navigating the menu hierarchy.

onCheckedChange: (Boolean) -> Unit

callback to be invoked when checkbox is being clicked, therefore the change of checked state in requested

Item

@Composable
fun Item(
    text: String,
    icon: Painter? = null,
    enabled: Boolean = true,
    mnemonic: Char? = null,
    shortcut: KeyShortcut? = null,
    onClick: () -> Unit
): Unit

Adds item to the menu

Parameters
text: String

text of the item that will be shown in the menu

icon: Painter? = null

icon of the item

enabled: Boolean = true

is this item item can be chosen

mnemonic: Char? = null

character that corresponds to some key on the keyboard. When this key will be pressed - onClick will be triggered. If the character is found within the item's text, the first occurrence of it will be underlined.

shortcut: KeyShortcut? = null

key combination which triggers onClick action without navigating the menu hierarchy.

onClick: () -> Unit

action that should be performed when the user clicks on the item

@Composable
fun Menu(
    text: String,
    enabled: Boolean = true,
    mnemonic: Char? = null,
    content: @Composable MenuScope.() -> Unit
): Unit

Adds sub menu to the menu

Parameters
text: String

text of the menu that will be shown in the menu

enabled: Boolean = true

is this menu item can be chosen

mnemonic: Char? = null

character that corresponds to some key on the keyboard. When this key will be pressed - menu will be open. If the character is found within the item's text, the first occurrence of it will be underlined.

content: @Composable MenuScope.() -> Unit

content of the menu (sub menus, items, separators, etc)

RadioButtonItem

@Composable
fun RadioButtonItem(
    text: String,
    selected: Boolean,
    icon: Painter? = null,
    enabled: Boolean = true,
    mnemonic: Char? = null,
    shortcut: KeyShortcut? = null,
    onClick: () -> Unit
): Unit

Adds item with radio button to the menu

Parameters
text: String

text of the item that will be shown in the menu

selected: Boolean

boolean state for this button: either it is selected or not

icon: Painter? = null

icon of the item

enabled: Boolean = true

is this item item can be chosen

mnemonic: Char? = null

character that corresponds to some key on the keyboard. When this key will be pressed - onClick will be triggered. If the character is found within the item's text, the first occurrence of it will be underlined.

shortcut: KeyShortcut? = null

key combination which triggers onClick action without navigating the menu hierarchy.

onClick: () -> Unit

callback to be invoked when the radio button is being clicked

Separator

@Composable
fun Separator(): Unit

Adds separator to the menu