TrayMenuHost

class TrayMenuHost(parentContext: CompositionContext, display: (popup: JPopupMenu, x: Int, y: Int) -> Unit = ::showPopupAtCursor, menu: @Composable () -> Unit)

Builds and presents the popup menu of a Tray. On each showMenu call it composes menu fresh into a JPopupMenu nested in parentContext, so the menu reflects the current composition state, then hands the populated popup to display. The menu composition is disposed when the popup closes, when a newer showMenu call replaces it, or when closeMenu closes it.

Parameters

parentContext

the composition context the popup menu nests into.

display

presents the populated popup at the gesture point; the production default shows it over a transient invoker at those screen coordinates.

menu

the composable menu tree opened on each showMenu call.

Constructors

Link copied to clipboard
constructor(parentContext: CompositionContext, display: (popup: JPopupMenu, x: Int, y: Int) -> Unit = ::showPopupAtCursor, menu: @Composable () -> Unit)

Functions

Link copied to clipboard
fun closeMenu()

Closes the menu last shown by showMenu: hides its popup and disposes its menu composition. A no-op when no menu is open, so it is safe to call repeatedly.

Link copied to clipboard
fun showMenu(x: Int, y: Int)

Composes menu into a fresh JPopupMenu and presents it through display at (x, y), closing the previously shown menu first.