Package-level declarations

Types

Link copied to clipboard
@Stable
class PopupAnchor

A hoistable handle naming the component a menu opens against, bound to one with popupAnchor.

Link copied to clipboard
sealed interface RadioButtonMenuGroupScope

Declarative choices of a RadioButtonMenuGroup. Each option call appends one radio button menu item, in call order; its position is the index reported to RadioButtonMenuGroup's onSelectionChange and matched against selectedIndex.

Functions

Link copied to clipboard
@Composable
fun CheckBoxMenuItem(text: @Nls String, checked: Boolean, actionListener: ActionListener, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

A JCheckBoxMenuItem driven by a raw ActionListener instead of an onCheckedChange lambda. The listener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn.

@Composable
fun CheckBoxMenuItem(text: @Nls String, checked: Boolean, onCheckedChange: (Boolean) -> Unit, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

A menu item carrying a checkmark: a JCheckBoxMenuItem that shows checked and reports the user's toggle through onCheckedChange.

Link copied to clipboard
@Composable
fun ContextMenu(anchor: PopupAnchor, onOpen: () -> Unit = {}, onClose: () -> Unit = {}, content: @Composable () -> Unit)

The menu the platform's popup gesture opens over the component anchor is bound to - a right-click, or whatever else the look and feel gives that gesture, the keyboard binding included.

@Composable
fun ContextMenu(anchor: PopupAnchor, display: (popup: JPopupMenu, invoker: Component, x: Int, y: Int) -> Unit, onOpen: () -> Unit = {}, onClose: () -> Unit = {}, content: @Composable () -> Unit)

Variant of ContextMenu that lets the caller decide how the populated JPopupMenu is presented, instead of the default of showing it over the component at the trigger point.

Link copied to clipboard
@Composable
fun Menu(text: @Nls String, modifier: SwingModifier = SwingModifier, content: @Composable () -> Unit = {})

An item that opens onto other items instead of acting itself: a JMenu, a pull-down in a menu bar or a submenu of another menu.

Link copied to clipboard
@Composable
fun MenuItem(text: @Nls String, actionListener: ActionListener, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

A JMenuItem driven by a raw ActionListener instead of an onClick lambda. The listener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn.

@Composable
fun MenuItem(text: @Nls String, onClick: () -> Unit, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

An item that performs an action when the user picks it: a JMenuItem reporting the pick through onClick.

Link copied to clipboard
@Composable
fun MenuSeparator(modifier: SwingModifier = SwingModifier)

The rule a menu draws between groups of items: a JPopupMenu.Separator, which shows no text and is not one of the items the menu's navigation moves through.

Link copied to clipboard

Binds anchor to this component, so a menu declared against that anchor opens over it. The binding follows the modifier: it ends when the modifier leaves the chain or the component leaves the composition, and a different anchor declared on a later recomposition takes the binding over from the previous one.

Link copied to clipboard
@Composable
fun PopupMenu(anchor: PopupAnchor, expanded: Boolean, onDismiss: () -> Unit, content: @Composable () -> Unit)

A menu the application opens itself - a drop-down button, an overflow menu, a shortcut - shown over the component anchor is bound to.

@Composable
fun PopupMenu(anchor: PopupAnchor, expanded: Boolean, display: (popup: JPopupMenu, invoker: Component, x: Int, y: Int) -> Unit, onDismiss: () -> Unit, content: @Composable () -> Unit)

Variant of PopupMenu that lets the caller decide how the populated JPopupMenu is presented, instead of the default of showing it at the anchor point under the bound component.

Link copied to clipboard
@Composable
fun RadioButtonMenuGroup(selectedIndex: Int, onSelectionChange: (Int) -> Unit, content: RadioButtonMenuGroupScope.() -> Unit)

A set of mutually exclusive choices in a menu, backed by a shared ButtonGroup, so at most one option is selected at a time.

Link copied to clipboard
@Composable
fun RadioButtonMenuItem(text: @Nls String, selected: Boolean, actionListener: ActionListener, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

A JRadioButtonMenuItem driven by a raw ActionListener instead of an onSelectedChange lambda. The listener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn.

@Composable
fun RadioButtonMenuItem(text: @Nls String, selected: Boolean, onSelectedChange: (Boolean) -> Unit, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

A menu item carrying a radio mark: a JRadioButtonMenuItem that shows selected and reports the user's activation through onSelectedChange. The item stands on its own, so activating it toggles the mark; for a set of items where at most one is marked, use RadioButtonMenuGroup.

Link copied to clipboard

Creates and remembers a PopupAnchor for the composition it is called in.