androidx.compose.ui.window

Interfaces

ApplicationScope

Scope used by application, awaitApplication, launchApplication

android
DialogState

A state object that can be hoisted to control and observe dialog attributes (size/position).

android
DialogWindowProvider

Provides the underlying window of a dialog.

android
DialogWindowScope

Receiver scope which is used by androidx.compose.ui.window.Dialog.

android
FrameWindowScope

Receiver scope which is used by androidx.compose.ui.window.Window.

android
PopupPositionProvider

Calculates the position of a Popup on screen.

Cmn
WindowScope

Receiver scope which is used by androidx.compose.ui.window.Window and androidx.compose.ui.window.Dialog.

android
WindowState

A state object that can be hoisted to control and observe window attributes (size/position/state).

android

Classes

DialogProperties

Properties used to customize the behavior of a Dialog.

Cmn
android
MenuBarScope

Receiver scope which is used by JMenuBar.setContent and FrameWindowScope.MenuBar.

android
MenuScope

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

android
Notification

Notification, that can be sent to the platform and be shown to the user (in tray, notification center, etc; depends on the platform).

android
PopupProperties

Properties used to customize the behavior of a Popup.

Cmn
android
TrayState

A state object that can be hoisted to control tray and show notifications.

android
WindowPosition

Position of the window or dialog on the screen in Dp.

android
WindowPosition.Absolute

Absolute position of the window on the current window screen

android
WindowPosition.Aligned

Window will be aligned when it will be shown on the screen.

android
WindowSize

This class is deprecated. Use DpSize

android

Objects

WindowPosition.PlatformDefault

Initial position of the window that depends on the platform.

android

Enums

Notification.Type

Describes the type of the notification.

android
SecureFlagPolicy

Policy on setting WindowManager.LayoutParams.FLAG_SECURE on a window.

android
WindowPlacement

Describes how the window is placed on the screen.

android

Top-level functions summary

Unit
@Composable
<T : Window> AwtWindow(
    visible: Boolean,
    create: () -> T,
    dispose: (T) -> Unit,
    update: (T) -> Unit
)

Compose Window obtained from create.

android
Unit
@Composable
Dialog(
    onDismissRequest: () -> Unit,
    properties: DialogProperties,
    content: @Composable () -> Unit
)

Opens a dialog with the given content.

Cmn
android
Unit
@Composable
Dialog(
    visible: Boolean,
    onPreviewKeyEvent: (KeyEvent) -> Boolean,
    onKeyEvent: (KeyEvent) -> Boolean,
    create: () -> ComposeDialog,
    dispose: (ComposeDialog) -> Unit,
    update: (ComposeDialog) -> Unit,
    content: @Composable DialogWindowScope.() -> Unit
)

This function is deprecated. Replaced by DialogWindow

android
Unit
@Composable
Dialog(
    onCloseRequest: () -> Unit,
    state: DialogState,
    visible: Boolean,
    title: String,
    icon: Painter?,
    undecorated: Boolean,
    transparent: Boolean,
    resizable: Boolean,
    enabled: Boolean,
    focusable: Boolean,
    onPreviewKeyEvent: (KeyEvent) -> Boolean,
    onKeyEvent: (KeyEvent) -> Boolean,
    content: @Composable DialogWindowScope.() -> Unit
)

This function is deprecated. Replaced by DialogWindow

android
DialogState
DialogState(position: WindowPosition, size: DpSize)

A state object that can be hoisted to control and observe dialog attributes (size/position).

android
DialogState

This function is deprecated. Use DialogState which accepts DpSize

android
DialogState
DialogState(position: WindowPosition, width: Dp, height: Dp)

A state object that can be hoisted to control and observe dialog attributes (size/position).

android
Unit
@Composable
DialogWindow(
    visible: Boolean,
    onPreviewKeyEvent: (KeyEvent) -> Boolean,
    onKeyEvent: (KeyEvent) -> Boolean,
    create: () -> ComposeDialog,
    dispose: (ComposeDialog) -> Unit,
    update: (ComposeDialog) -> Unit,
    content: @Composable DialogWindowScope.() -> Unit
)

Compose ComposeDialog obtained from create.

android
Unit
@Composable
DialogWindow(
    onCloseRequest: () -> Unit,
    state: DialogState,
    visible: Boolean,
    title: String,
    icon: Painter?,
    undecorated: Boolean,
    transparent: Boolean,
    resizable: Boolean,
    enabled: Boolean,
    focusable: Boolean,
    onPreviewKeyEvent: (KeyEvent) -> Boolean,
    onKeyEvent: (KeyEvent) -> Boolean,
    content: @Composable DialogWindowScope.() -> Unit
)

Composes platform dialog in the current composition.

android
Unit
@Composable
Popup(
    popupPositionProvider: PopupPositionProvider,
    onDismissRequest: (() -> Unit)?,
    properties: PopupProperties,
    content: @Composable () -> Unit
)

Opens a popup with the given content.

Cmn
android
Unit
@Composable
Popup(
    alignment: Alignment,
    offset: IntOffset,
    onDismissRequest: (() -> Unit)?,
    properties: PopupProperties,
    content: @Composable () -> Unit
)

Opens a popup with the given content.

Cmn
android
Unit
@Composable
Popup(
    popupPositionProvider: PopupPositionProvider,
    onDismissRequest: (() -> Unit)?,
    onPreviewKeyEvent: (KeyEvent) -> Boolean,
    onKeyEvent: (KeyEvent) -> Boolean,
    focusable: Boolean,
    content: @Composable () -> Unit
)

Opens a popup with the given content.

android
Unit
@Composable
Popup(
    alignment: Alignment,
    offset: IntOffset,
    focusable: Boolean,
    onDismissRequest: (() -> Unit)?,
    onPreviewKeyEvent: (KeyEvent) -> Boolean,
    onKeyEvent: (KeyEvent) -> Boolean,
    content: @Composable () -> Unit
)

Opens a popup with the given content.

android
Unit
@Composable
Window(
    visible: Boolean,
    onPreviewKeyEvent: (KeyEvent) -> Boolean,
    onKeyEvent: (KeyEvent) -> Boolean,
    create: () -> ComposeWindow,
    dispose: (ComposeWindow) -> Unit,
    update: (ComposeWindow) -> Unit,
    content: @Composable FrameWindowScope.() -> Unit
)

Compose ComposeWindow obtained from create.

android
Unit
@Composable
Window(
    onCloseRequest: () -> Unit,
    state: WindowState,
    visible: Boolean,
    title: String,
    icon: Painter?,
    undecorated: Boolean,
    transparent: Boolean,
    resizable: Boolean,
    enabled: Boolean,
    focusable: Boolean,
    alwaysOnTop: Boolean,
    onPreviewKeyEvent: (KeyEvent) -> Boolean,
    onKeyEvent: (KeyEvent) -> Boolean,
    content: @Composable FrameWindowScope.() -> Unit
)

Composes platform window in the current composition.

android
WindowPosition.Aligned

Constructs an WindowPosition.Aligned from alignment value.

android
WindowPosition.Absolute
WindowPosition(x: Dp, y: Dp)

Constructs an WindowPosition.Absolute from x and y values.

android
WindowSize
WindowSize(width: Dp, height: Dp)

This function is deprecated. Use DpSize

android
WindowState
WindowState(
    placement: WindowPlacement,
    isMinimized: Boolean,
    position: WindowPosition,
    size: DpSize
)

A state object that can be hoisted to control and observe window attributes (size/position/state).

android
WindowState
WindowState(
    placement: WindowPlacement,
    isMinimized: Boolean,
    position: WindowPosition,
    size: WindowSize
)

This function is deprecated. Use WindowState which accepts DpSize

android
WindowState
WindowState(
    placement: WindowPlacement,
    isMinimized: Boolean,
    position: WindowPosition,
    width: Dp,
    height: Dp
)

A state object that can be hoisted to control and observe window attributes (size/position/state).

android
Unit

An entry point for the Compose application.

android
suspend Unit

An entry point for the Compose application.

android
Boolean
@TestOnly
isPopupLayout(view: View, testTag: String?)

Returns whether the given view is an underlying decor view of a popup.

android
PopupPositionProvider
@Composable
rememberComponentRectPositionProvider(
    anchor: Alignment,
    alignment: Alignment,
    offset: DpOffset
)

Provides PopupPositionProvider relative to the current component bounds.

android
PopupPositionProvider
@Composable
rememberCursorPositionProvider(
    offset: DpOffset,
    alignment: Alignment,
    windowMargin: Dp
)

Provides PopupPositionProvider relative to the current mouse cursor position.

android
DialogState

Creates a DialogState that is remembered across compositions.

android
DialogState

This function is deprecated. Use rememberDialogState which accepts DpSize

android
DialogState
@Composable
rememberDialogState(position: WindowPosition, width: Dp, height: Dp)

Creates a DialogState that is remembered across compositions.

android
Notification
@Composable
rememberNotification(
    title: String,
    message: String,
    type: Notification.Type
)

Creates a Notification that is remembered across compositions.

android
TrayState

Creates a WindowState that is remembered across compositions.

android
WindowState
@Composable
rememberWindowState(
    placement: WindowPlacement,
    isMinimized: Boolean,
    position: WindowPosition,
    size: DpSize
)

Creates a WindowState that is remembered across compositions.

android
WindowState
@Composable
rememberWindowState(
    placement: WindowPlacement,
    isMinimized: Boolean,
    position: WindowPosition,
    size: WindowSize
)

This function is deprecated. Use rememberWindowState which accepts DpSize

android
WindowState
@Composable
rememberWindowState(
    placement: WindowPlacement,
    isMinimized: Boolean,
    position: WindowPosition,
    width: Dp,
    height: Dp
)

Creates a WindowState that is remembered across compositions.

android
Unit
singleWindowApplication(
    state: WindowState,
    visible: Boolean,
    title: String,
    icon: Painter?,
    undecorated: Boolean,
    transparent: Boolean,
    resizable: Boolean,
    enabled: Boolean,
    focusable: Boolean,
    alwaysOnTop: Boolean,
    onPreviewKeyEvent: (KeyEvent) -> Boolean,
    onKeyEvent: (KeyEvent) -> Boolean,
    content: @Composable FrameWindowScope.() -> Unit
)

An entry point for the Compose application with single window.

android

Extension functions summary

Unit

Composes menu bar on the top of the window

android
Unit
@Composable
ApplicationScope.Tray(
    icon: Painter,
    state: TrayState,
    tooltip: String?,
    onAction: () -> Unit,
    menu: @Composable MenuScope.() -> Unit
)

Adds tray icon to the platform taskbar if it is supported.

android
Job

Short variant of launching application inside CoroutineScope.

android
Composition
JMenuBar.setContent(
    parentComposition: CompositionContext,
    content: @Composable MenuBarScope.() -> Unit
)

Composes the given composable into the MenuBar.

android
Composition
Menu.setContent(
    parentComposition: CompositionContext,
    content: @Composable MenuScope.() -> Unit
)

Composes the given composable into the Menu.

android
Composition
JMenu.setContent(
    parentComposition: CompositionContext,
    content: @Composable MenuScope.() -> Unit
)

Composes the given composable into the Menu.

android

Top-level properties summary

Boolean

true if the platform supports tray icons in the taskbar

android

Top-level functions

AwtWindow

@Composable
fun <T : Window> AwtWindow(
    visible: Boolean = true,
    create: () -> T,
    dispose: (T) -> Unit,
    update: (T) -> Unit = {}
): Unit

Compose Window obtained from create. The create block will be called exactly once to obtain the Window to be composed, and it is also guaranteed to be invoked on the UI thread (Event Dispatch Thread).

Once AwtWindow leaves the composition, dispose will be called to free resources that obtained by the Window.

The update block can be run multiple times (on the UI thread as well) due to recomposition, and it is the right place to set Window properties depending on state. When state changes, the block will be reexecuted to set the new properties. Note the block will also be ran once right after the create block completes.

AwtWindow is needed for creating window's / dialog's that still can't be created with the default Compose functions androidx.compose.ui.window.Window or androidx.compose.ui.window.Dialog.

Parameters
visible: Boolean = true

Is Window visible to user. Note that if we set false - native resources will not be released. They will be released only when Window will leave the composition.

create: () -> T

The block creating the Window to be composed.

dispose: (T) -> Unit

The block to dispose Window and free native resources. Usually it is simple Window::dispose

update: (T) -> Unit = {}

The callback to be invoked after the layout is inflated.

Dialog

@Composable
fun Dialog(
    onDismissRequest: () -> Unit,
    properties: DialogProperties = DialogProperties(),
    content: @Composable () -> Unit
): Unit

Opens a dialog with the given content.

A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.

The dialog is visible as long as it is part of the composition hierarchy. In order to let the user dismiss the Dialog, the implementation of onDismissRequest should contain a way to remove the dialog from the composition hierarchy.

Example usage:

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.window.Dialog

val openDialog = remember { mutableStateOf(true) }
val dialogWidth = 200.dp
val dialogHeight = 50.dp

if (openDialog.value) {
    Dialog(onDismissRequest = { openDialog.value = false }) {
        // Draw a rectangle shape with rounded corners inside the dialog
        Box(Modifier.size(dialogWidth, dialogHeight).background(Color.White))
    }
}
Parameters
onDismissRequest: () -> Unit

Executes when the user tries to dismiss the dialog.

properties: DialogProperties = DialogProperties()

DialogProperties for further customization of this dialog's behavior.

content: @Composable () -> Unit

The content to be displayed inside the dialog.

Dialog

@Composable
fun Dialog(
    visible: Boolean = true,
    onPreviewKeyEvent: (KeyEvent) -> Boolean = { false },
    onKeyEvent: (KeyEvent) -> Boolean = { false },
    create: () -> ComposeDialog,
    dispose: (ComposeDialog) -> Unit,
    update: (ComposeDialog) -> Unit = {},
    content: @Composable DialogWindowScope.() -> Unit
): Unit

Dialog

@Composable
fun Dialog(
    onCloseRequest: () -> Unit,
    state: DialogState = rememberDialogState(),
    visible: Boolean = true,
    title: String = "Untitled",
    icon: Painter? = null,
    undecorated: Boolean = false,
    transparent: Boolean = false,
    resizable: Boolean = true,
    enabled: Boolean = true,
    focusable: Boolean = true,
    onPreviewKeyEvent: (KeyEvent) -> Boolean = { false },
    onKeyEvent: (KeyEvent) -> Boolean = { false },
    content: @Composable DialogWindowScope.() -> Unit
): Unit

DialogState

fun DialogState(
    position: WindowPosition = WindowPosition(Alignment.Center),
    size: DpSize = DpSize(400.dp, 300.dp)
): DialogState

A state object that can be hoisted to control and observe dialog attributes (size/position).

Parameters
position: WindowPosition = WindowPosition(Alignment.Center)

the initial value for DialogState.position

size: DpSize = DpSize(400.dp, 300.dp)

the initial value for DialogState.size

DialogState

fun DialogState(
    position: WindowPosition = WindowPosition(Alignment.Center),
    size: WindowSize
): DialogState

A state object that can be hoisted to control and observe dialog attributes (size/position).

Parameters
position: WindowPosition = WindowPosition(Alignment.Center)

the initial value for DialogState.position

size: WindowSize

the initial value for DialogState.size

DialogState

fun DialogState(
    position: WindowPosition = WindowPosition(Alignment.Center),
    width: Dp = 400.dp,
    height: Dp = 300.dp
): DialogState

A state object that can be hoisted to control and observe dialog attributes (size/position).

Parameters
position: WindowPosition = WindowPosition(Alignment.Center)

the initial value for DialogState.position

width: Dp = 400.dp

the initial value for width of WindowState.size

height: Dp = 300.dp

the initial value for height of WindowState.size

DialogWindow

@Composable
fun DialogWindow(
    visible: Boolean = true,
    onPreviewKeyEvent: (KeyEvent) -> Boolean = { false },
    onKeyEvent: (KeyEvent) -> Boolean = { false },
    create: () -> ComposeDialog,
    dispose: (ComposeDialog) -> Unit,
    update: (ComposeDialog) -> Unit = {},
    content: @Composable DialogWindowScope.() -> Unit
): Unit

Compose ComposeDialog obtained from create. The create block will be called exactly once to obtain the ComposeDialog to be composed, and it is also guaranteed to be invoked on the UI thread (Event Dispatch Thread).

Once Dialog leaves the composition, dispose will be called to free resources that obtained by the ComposeDialog.

Dialog is a modal window. It means it blocks the parent Window / Dialog in which composition context it was created.

The update block can be run multiple times (on the UI thread as well) due to recomposition, and it is the right place to set ComposeDialog properties depending on state. When state changes, the block will be reexecuted to set the new properties. Note the block will also be ran once right after the create block completes.

Dialog is needed for creating dialog's that still can't be created with the default Compose function androidx.compose.ui.window.Dialog

Parameters
visible: Boolean = true

Is ComposeDialog visible to user. If false:

  • internal state of ComposeDialog is preserved and will be restored next time the dialog will be visible;

  • native resources will not be released. They will be released only when Dialog will leave the composition.

onPreviewKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. It gives ancestors of a focused component the chance to intercept a KeyEvent. Return true to stop propagation of this event. If you return false, the key event will be sent to this onPreviewKeyEvent's child. If none of the children consume the event, it will be sent back up to the root using the onKeyEvent callback.

onKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. While implementing this callback, return true to stop propagation of this event. If you return false, the key event will be sent to this onKeyEvent's parent.

create: () -> ComposeDialog

The block creating the ComposeDialog to be composed.

dispose: (ComposeDialog) -> Unit

The block to dispose ComposeDialog and free native resources. Usually it is simple ComposeDialog::dispose

update: (ComposeDialog) -> Unit = {}

The callback to be invoked after the layout is inflated.

content: @Composable DialogWindowScope.() -> Unit

Composable content of the creating dialog.

DialogWindow

@Composable
fun DialogWindow(
    onCloseRequest: () -> Unit,
    state: DialogState = rememberDialogState(),
    visible: Boolean = true,
    title: String = "Untitled",
    icon: Painter? = null,
    undecorated: Boolean = false,
    transparent: Boolean = false,
    resizable: Boolean = true,
    enabled: Boolean = true,
    focusable: Boolean = true,
    onPreviewKeyEvent: (KeyEvent) -> Boolean = { false },
    onKeyEvent: (KeyEvent) -> Boolean = { false },
    content: @Composable DialogWindowScope.() -> Unit
): Unit

Composes platform dialog in the current composition. When Dialog enters the composition, a new platform dialog will be created and receives the focus. When Dialog leaves the composition, dialog will be disposed and closed.

Dialog is a modal window. It means it blocks the parent Window / Dialog in which composition context it was created.

Usage:

@Composable
fun main() = application {
val isDialogOpen by remember { mutableStateOf(true) }
if (isDialogOpen) {
Dialog(onCloseRequest = { isDialogOpen = false })
}
}
Parameters
onCloseRequest: () -> Unit

Callback that will be called when the user closes the dialog. Usually in this callback we need to manually tell Compose what to do:

  • change isOpen state of the dialog (which is manually defined)

  • close the whole application (onCloseRequest = ::exitApplication in ApplicationScope)

  • don't close the dialog on close request (onCloseRequest = {})

state: DialogState = rememberDialogState()

The state object to be used to control or observe the dialog's state When size/position is changed by the user, state will be updated. When size/position of the dialog is changed by the application (changing state), the native dialog will update its corresponding properties. If DialogState.position is not WindowPosition.isSpecified, then after the first show on the screen DialogState.position will be set to the absolute values.

visible: Boolean = true

Is Dialog visible to user. If false:

  • internal state of Dialog is preserved and will be restored next time the dialog will be visible;

  • native resources will not be released. They will be released only when Dialog will leave the composition.

title: String = "Untitled"

Title in the titlebar of the dialog

icon: Painter? = null

Icon in the titlebar of the window (for platforms which support this). On macOs individual windows can't have a separate icon. To change the icon in the Dock, set it via iconFile in build.gradle (https://github.com/JetBrains/compose-jb/tree/master/tutorials/Native_distributions_and_local_execution#platform-specific-options)

undecorated: Boolean = false

Disables or enables decorations for this window.

transparent: Boolean = false

Disables or enables window transparency. Transparency should be set only if window is undecorated, otherwise an exception will be thrown.

resizable: Boolean = true

Can dialog be resized by the user (application still can resize the dialog changing state)

enabled: Boolean = true

Can dialog react to input events

focusable: Boolean = true

Can dialog receive focus

onPreviewKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. It gives ancestors of a focused component the chance to intercept a KeyEvent. Return true to stop propagation of this event. If you return false, the key event will be sent to this onPreviewKeyEvent's child. If none of the children consume the event, it will be sent back up to the root using the onKeyEvent callback.

onKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. While implementing this callback, return true to stop propagation of this event. If you return false, the key event will be sent to this onKeyEvent's parent.

content: @Composable DialogWindowScope.() -> Unit

content of the dialog

Popup

@Composable
fun Popup(
    popupPositionProvider: PopupPositionProvider,
    onDismissRequest: (() -> Unit)? = null,
    properties: PopupProperties = @OptIn(ExperimentalComposeUiApi::class) PopupProperties(),
    content: @Composable () -> Unit
): Unit

Opens a popup with the given content.

The popup is positioned using a custom popupPositionProvider.

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.ui.window.Popup

Box {
    val popupWidth = 200.dp
    val popupHeight = 50.dp
    val cornerSize = 16.dp

    Popup(alignment = Alignment.Center) {
        // Draw a rectangle shape with rounded corners inside the popup
        Box(
            Modifier
                .size(popupWidth, popupHeight)
                .background(Color.White, RoundedCornerShape(cornerSize))
        )
    }
}
Parameters
popupPositionProvider: PopupPositionProvider

Provides the screen position of the popup.

onDismissRequest: (() -> Unit)? = null

Executes when the user clicks outside of the popup.

properties: PopupProperties = @OptIn(ExperimentalComposeUiApi::class) PopupProperties()

PopupProperties for further customization of this popup's behavior.

content: @Composable () -> Unit

The content to be displayed inside the popup.

Popup

@Composable
fun Popup(
    alignment: Alignment = Alignment.TopStart,
    offset: IntOffset = IntOffset(0, 0),
    onDismissRequest: (() -> Unit)? = null,
    properties: PopupProperties = @OptIn(ExperimentalComposeUiApi::class) PopupProperties(),
    content: @Composable () -> Unit
): Unit

Opens a popup with the given content.

A popup is a floating container that appears on top of the current activity. It is especially useful for non-modal UI surfaces that remain hidden until they are needed, for example floating menus like Cut/Copy/Paste.

The popup is positioned relative to its parent, using the alignment and offset. The popup is visible as long as it is part of the composition hierarchy.

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.ui.window.Popup

Box {
    val popupWidth = 200.dp
    val popupHeight = 50.dp
    val cornerSize = 16.dp

    Popup(alignment = Alignment.Center) {
        // Draw a rectangle shape with rounded corners inside the popup
        Box(
            Modifier
                .size(popupWidth, popupHeight)
                .background(Color.White, RoundedCornerShape(cornerSize))
        )
    }
}
Parameters
alignment: Alignment = Alignment.TopStart

The alignment relative to the parent.

offset: IntOffset = IntOffset(0, 0)

An offset from the original aligned position of the popup. Offset respects the Ltr/Rtl context, thus in Ltr it will be added to the original aligned position and in Rtl it will be subtracted from it.

onDismissRequest: (() -> Unit)? = null

Executes when the user clicks outside of the popup.

properties: PopupProperties = @OptIn(ExperimentalComposeUiApi::class) PopupProperties()

PopupProperties for further customization of this popup's behavior.

content: @Composable () -> Unit

The content to be displayed inside the popup.

Popup

@Composable
fun Popup(
    popupPositionProvider: PopupPositionProvider,
    onDismissRequest: (() -> Unit)? = null,
    onPreviewKeyEvent: (KeyEvent) -> Boolean = { false },
    onKeyEvent: (KeyEvent) -> Boolean = { false },
    focusable: Boolean = false,
    content: @Composable () -> Unit
): Unit

Opens a popup with the given content.

The popup is positioned using a custom popupPositionProvider.

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.ui.window.Popup

Box {
    val popupWidth = 200.dp
    val popupHeight = 50.dp
    val cornerSize = 16.dp

    Popup(alignment = Alignment.Center) {
        // Draw a rectangle shape with rounded corners inside the popup
        Box(
            Modifier
                .size(popupWidth, popupHeight)
                .background(Color.White, RoundedCornerShape(cornerSize))
        )
    }
}
Parameters
popupPositionProvider: PopupPositionProvider

Provides the screen position of the popup.

onDismissRequest: (() -> Unit)? = null

Executes when the user clicks outside of the popup.

onPreviewKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. It gives ancestors of a focused component the chance to intercept a KeyEvent. Return true to stop propagation of this event. If you return false, the key event will be sent to this onPreviewKeyEvent's child. If none of the children consume the event, it will be sent back up to the root using the onKeyEvent callback.

onKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. While implementing this callback, return true to stop propagation of this event. If you return false, the key event will be sent to this onKeyEvent's parent.

focusable: Boolean = false

Indicates if the popup can grab the focus.

content: @Composable () -> Unit

The content to be displayed inside the popup.

Popup

@Composable
fun Popup(
    alignment: Alignment = Alignment.TopStart,
    offset: IntOffset = IntOffset(0, 0),
    focusable: Boolean = false,
    onDismissRequest: (() -> Unit)? = null,
    onPreviewKeyEvent: (KeyEvent) -> Boolean = { false },
    onKeyEvent: (KeyEvent) -> Boolean = { false },
    content: @Composable () -> Unit
): Unit

Opens a popup with the given content.

The popup is positioned relative to its parent, using the alignment and offset. The popup is visible as long as it is part of the composition hierarchy.

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.ui.window.Popup

Box {
    val popupWidth = 200.dp
    val popupHeight = 50.dp
    val cornerSize = 16.dp

    Popup(alignment = Alignment.Center) {
        // Draw a rectangle shape with rounded corners inside the popup
        Box(
            Modifier
                .size(popupWidth, popupHeight)
                .background(Color.White, RoundedCornerShape(cornerSize))
        )
    }
}
Parameters
alignment: Alignment = Alignment.TopStart

The alignment relative to the parent.

offset: IntOffset = IntOffset(0, 0)

An offset from the original aligned position of the popup. Offset respects the Ltr/Rtl context, thus in Ltr it will be added to the original aligned position and in Rtl it will be subtracted from it.

focusable: Boolean = false

Indicates if the popup can grab the focus.

onDismissRequest: (() -> Unit)? = null

Executes when the user clicks outside of the popup.

onPreviewKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. It gives ancestors of a focused component the chance to intercept a KeyEvent. Return true to stop propagation of this event. If you return false, the key event will be sent to this onPreviewKeyEvent's child. If none of the children consume the event, it will be sent back up to the root using the onKeyEvent callback.

onKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. While implementing this callback, return true to stop propagation of this event. If you return false, the key event will be sent to this onKeyEvent's parent.

content: @Composable () -> Unit

The content to be displayed inside the popup.

Window

@Composable
fun Window(
    visible: Boolean = true,
    onPreviewKeyEvent: (KeyEvent) -> Boolean = { false },
    onKeyEvent: (KeyEvent) -> Boolean = { false },
    create: () -> ComposeWindow,
    dispose: (ComposeWindow) -> Unit,
    update: (ComposeWindow) -> Unit = {},
    content: @Composable FrameWindowScope.() -> Unit
): Unit

Compose ComposeWindow obtained from create. The create block will be called exactly once to obtain the ComposeWindow to be composed, and it is also guaranteed to be invoked on the UI thread (Event Dispatch Thread).

Once Window leaves the composition, dispose will be called to free resources that obtained by the ComposeWindow.

The update block can be run multiple times (on the UI thread as well) due to recomposition, and it is the right place to set ComposeWindow properties depending on state. When state changes, the block will be reexecuted to set the new properties. Note the block will also be ran once right after the create block completes.

Window is needed for creating window's that still can't be created with the default Compose function androidx.compose.ui.window.Window

Parameters
visible: Boolean = true

Is ComposeWindow visible to user. If false:

  • internal state of ComposeWindow is preserved and will be restored next time the window will be visible;

  • native resources will not be released. They will be released only when Window will leave the composition.

onPreviewKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. It gives ancestors of a focused component the chance to intercept a KeyEvent. Return true to stop propagation of this event. If you return false, the key event will be sent to this onPreviewKeyEvent's child. If none of the children consume the event, it will be sent back up to the root using the onKeyEvent callback.

onKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. While implementing this callback, return true to stop propagation of this event. If you return false, the key event will be sent to this onKeyEvent's parent.

create: () -> ComposeWindow

The block creating the ComposeWindow to be composed.

dispose: (ComposeWindow) -> Unit

The block to dispose ComposeWindow and free native resources. Usually it is simple ComposeWindow::dispose

update: (ComposeWindow) -> Unit = {}

The callback to be invoked after the layout is inflated.

content: @Composable FrameWindowScope.() -> Unit

Composable content of the creating window.

Window

@Composable
fun Window(
    onCloseRequest: () -> Unit,
    state: WindowState = rememberWindowState(),
    visible: Boolean = true,
    title: String = "Untitled",
    icon: Painter? = null,
    undecorated: Boolean = false,
    transparent: Boolean = false,
    resizable: Boolean = true,
    enabled: Boolean = true,
    focusable: Boolean = true,
    alwaysOnTop: Boolean = false,
    onPreviewKeyEvent: (KeyEvent) -> Boolean = { false },
    onKeyEvent: (KeyEvent) -> Boolean = { false },
    content: @Composable FrameWindowScope.() -> Unit
): Unit

Composes platform window in the current composition. When Window enters the composition, a new platform window will be created and receives the focus. When Window leaves the composition, window will be disposed and closed.

Initial size of the window is controlled by WindowState.size. Initial position of the window is controlled by WindowState.position.

Usage in single-window application (ApplicationScope.exitApplication will close all the windows and stop all effects defined in application):

fun main() = application {
Window(onCloseRequest = ::exitApplication)
}

or if it only needed to close the main window without closing all other opened windows:

fun main() = application {
val isOpen by remember { mutableStateOf(true) }
if (isOpen) {
Window(onCloseRequest = { isOpen = false })
}
}
Parameters
onCloseRequest: () -> Unit

Callback that will be called when the user closes the window. Usually in this callback we need to manually tell Compose what to do:

  • change isOpen state of the window (which is manually defined)

  • close the whole application (onCloseRequest = ::exitApplication in ApplicationScope)

  • don't close the window on close request (onCloseRequest = {})

state: WindowState = rememberWindowState()

The state object to be used to control or observe the window's state When size/position/status is changed by the user, state will be updated. When size/position/status of the window is changed by the application (changing state), the native window will update its corresponding properties. If application changes, for example WindowState.placement, then after the next recomposition, WindowState.size will be changed to correspond the real size of the window. If WindowState.position is not WindowPosition.isSpecified, then after the first show on the screen WindowState.position will be set to the absolute values.

visible: Boolean = true

Is Window visible to user. If false:

  • internal state of Window is preserved and will be restored next time the window will be visible;

  • native resources will not be released. They will be released only when Window will leave the composition.

title: String = "Untitled"

Title in the titlebar of the window

icon: Painter? = null

Icon in the titlebar of the window (for platforms which support this). On macOs individual windows can't have a separate icon. To change the icon in the Dock, set it via iconFile in build.gradle (https://github.com/JetBrains/compose-jb/tree/master/tutorials/Native_distributions_and_local_execution#platform-specific-options)

undecorated: Boolean = false

Disables or enables decorations for this window.

transparent: Boolean = false

Disables or enables window transparency. Transparency should be set only if window is undecorated, otherwise an exception will be thrown.

resizable: Boolean = true

Can window be resized by the user (application still can resize the window changing state)

enabled: Boolean = true

Can window react to input events

focusable: Boolean = true

Can window receive focus

alwaysOnTop: Boolean = false

Should window always be on top of another windows

onPreviewKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. It gives ancestors of a focused component the chance to intercept a KeyEvent. Return true to stop propagation of this event. If you return false, the key event will be sent to this onPreviewKeyEvent's child. If none of the children consume the event, it will be sent back up to the root using the onKeyEvent callback.

onKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. While implementing this callback, return true to stop propagation of this event. If you return false, the key event will be sent to this onKeyEvent's parent.

content: @Composable FrameWindowScope.() -> Unit

Content of the window

WindowPosition

fun WindowPosition(alignment: Alignment): WindowPosition.Aligned

Constructs an WindowPosition.Aligned from alignment value.

WindowPosition

fun WindowPosition(x: Dp, y: Dp): WindowPosition.Absolute

Constructs an WindowPosition.Absolute from x and y values.

WindowSize

fun WindowSize(width: Dp, height: Dp): WindowSize

Constructs an WindowSize from width and height values.

WindowState

fun WindowState(
    placement: WindowPlacement = WindowPlacement.Floating,
    isMinimized: Boolean = false,
    position: WindowPosition = WindowPosition.PlatformDefault,
    size: DpSize = DpSize(800.dp, 600.dp)
): WindowState

A state object that can be hoisted to control and observe window attributes (size/position/state).

Parameters
placement: WindowPlacement = WindowPlacement.Floating

the initial value for WindowState.placement

isMinimized: Boolean = false

the initial value for WindowState.isMinimized

position: WindowPosition = WindowPosition.PlatformDefault

the initial value for WindowState.position

size: DpSize = DpSize(800.dp, 600.dp)

the initial value for WindowState.size

WindowState

fun WindowState(
    placement: WindowPlacement = WindowPlacement.Floating,
    isMinimized: Boolean = false,
    position: WindowPosition = WindowPosition.PlatformDefault,
    size: WindowSize
): WindowState

A state object that can be hoisted to control and observe window attributes (size/position/state).

Parameters
placement: WindowPlacement = WindowPlacement.Floating

the initial value for WindowState.placement

isMinimized: Boolean = false

the initial value for WindowState.isMinimized

position: WindowPosition = WindowPosition.PlatformDefault

the initial value for WindowState.position

size: WindowSize

the initial value for WindowState.size

WindowState

fun WindowState(
    placement: WindowPlacement = WindowPlacement.Floating,
    isMinimized: Boolean = false,
    position: WindowPosition = WindowPosition.PlatformDefault,
    width: Dp = 800.dp,
    height: Dp = 600.dp
): WindowState

A state object that can be hoisted to control and observe window attributes (size/position/state).

Parameters
placement: WindowPlacement = WindowPlacement.Floating

the initial value for WindowState.placement

isMinimized: Boolean = false

the initial value for WindowState.isMinimized

position: WindowPosition = WindowPosition.PlatformDefault

the initial value for WindowState.position

width: Dp = 800.dp

the initial value for width of WindowState.size

height: Dp = 600.dp

the initial value for height of WindowState.size

application

fun application(content: @Composable ApplicationScope.() -> Unit): Unit

An entry point for the Compose application. See awaitApplication for more information.

Usually this entry point is used inside main() function:

fun main() = application {

}

This entry point is a blocking operation (it blocks the current thread until application finishes) and can't be called inside UI thread. To launch new application from UI thread (for example, from some event listener), use GlobalScope.launchApplication instead.

This function is equivalent of:

runBlocking {
awaitApplication {

}
}
See also
awaitApplication

awaitApplication

suspend fun awaitApplication(content: @Composable ApplicationScope.() -> Unit): Unit

An entry point for the Compose application.

Application can launch background tasks using LaunchedEffect or create Window, Dialog, or Tray in a declarative Compose way:

fun main() = runBlocking {
withApplication {
val isSplashScreenShowing by remember { mutableStateOf(true) }

LaunchedEffect(Unit) {
delay(2000)
isSplashScreenShowing = false
}

if (isSplashScreenShowing) {
Window(title = "Splash") {}
} else {
Window(title = "App") {}
}
}
}

When there is no any active compositions, this function will end. Active composition is a composition that have active coroutine (for example, launched in LaunchedEffect) or that have child composition created inside Window, Dialog, or Tray.

Don't use any animation in this function (for example, withFrameNanos or androidx.compose.animation.core.animateFloatAsState), because underlying MonotonicFrameClock hasn't synchronized with any display, and produces frames as fast as possible.

All animation's should be created inside Composable content of the Window / Dialog / ComposePanel.

isPopupLayout

@TestOnly
fun isPopupLayout(view: View, testTag: String? = null): Boolean

Returns whether the given view is an underlying decor view of a popup. If the given testTag is supplied it also verifies that the popup has such tag assigned.

Parameters
view: View

View to verify.

testTag: String? = null

If provided, tests that the given tag in defined on the popup.

rememberComponentRectPositionProvider

@Composable
fun rememberComponentRectPositionProvider(
    anchor: Alignment = Alignment.BottomCenter,
    alignment: Alignment = Alignment.BottomCenter,
    offset: DpOffset = DpOffset.Zero
): PopupPositionProvider

Provides PopupPositionProvider relative to the current component bounds.

Parameters
anchor: Alignment = Alignment.BottomCenter

The anchor point relative to the current component bounds.

alignment: Alignment = Alignment.BottomCenter

The alignment of the popup relative to the anchor point.

offset: DpOffset = DpOffset.Zero

DpOffset to be added to the position of the popup.

rememberCursorPositionProvider

@Composable
fun rememberCursorPositionProvider(
    offset: DpOffset = DpOffset.Zero,
    alignment: Alignment = Alignment.BottomEnd,
    windowMargin: Dp = 4.dp
): PopupPositionProvider

Provides PopupPositionProvider relative to the current mouse cursor position.

Parameters
offset: DpOffset = DpOffset.Zero

DpOffset to be added to the position of the popup.

alignment: Alignment = Alignment.BottomEnd

The alignment of the popup relative to the current cursor position.

windowMargin: Dp = 4.dp

Defines the area within the window that limits the placement of the popup.

rememberDialogState

@Composable
fun rememberDialogState(
    position: WindowPosition = WindowPosition(Alignment.Center),
    size: DpSize = DpSize(400.dp, 300.dp)
): DialogState

Creates a DialogState that is remembered across compositions.

Changes to the provided initial values will not result in the state being recreated or changed in any way if it has already been created.

Parameters
position: WindowPosition = WindowPosition(Alignment.Center)

the initial value for DialogState.position

size: DpSize = DpSize(400.dp, 300.dp)

the initial value for DialogState.size

rememberDialogState

@Composable
fun rememberDialogState(
    position: WindowPosition = WindowPosition(Alignment.Center),
    size: WindowSize
): DialogState

Creates a DialogState that is remembered across compositions.

Changes to the provided initial values will not result in the state being recreated or changed in any way if it has already been created.

Parameters
position: WindowPosition = WindowPosition(Alignment.Center)

the initial value for DialogState.position

size: WindowSize

the initial value for DialogState.size

rememberDialogState

@Composable
fun rememberDialogState(
    position: WindowPosition = WindowPosition(Alignment.Center),
    width: Dp = 400.dp,
    height: Dp = 300.dp
): DialogState

Creates a DialogState that is remembered across compositions.

Changes to the provided initial values will not result in the state being recreated or changed in any way if it has already been created.

Parameters
position: WindowPosition = WindowPosition(Alignment.Center)

the initial value for DialogState.position

width: Dp = 400.dp

the initial value for width of WindowState.size

height: Dp = 300.dp

the initial value for height of WindowState.size

rememberNotification

@Composable
fun rememberNotification(
    title: String,
    message: String,
    type: Notification.Type = Notification.Type.None
): Notification

Creates a Notification that is remembered across compositions.

Parameters
title: String

Title of the notification

message: String

The main text of the notification

type: Notification.Type = Notification.Type.None

Type of the notification that defines how the notification will be represented to the user (with which icon and which sound)

rememberTrayState

@Composable
fun rememberTrayState(): TrayState

Creates a WindowState that is remembered across compositions.

rememberWindowState

@Composable
fun rememberWindowState(
    placement: WindowPlacement = WindowPlacement.Floating,
    isMinimized: Boolean = false,
    position: WindowPosition = WindowPosition.PlatformDefault,
    size: DpSize = DpSize(800.dp, 600.dp)
): WindowState

Creates a WindowState that is remembered across compositions.

Changes to the provided initial values will not result in the state being recreated or changed in any way if it has already been created.

Parameters
placement: WindowPlacement = WindowPlacement.Floating

the initial value for WindowState.placement

isMinimized: Boolean = false

the initial value for WindowState.isMinimized

position: WindowPosition = WindowPosition.PlatformDefault

the initial value for WindowState.position

size: DpSize = DpSize(800.dp, 600.dp)

the initial value for WindowState.size

rememberWindowState

@Composable
fun rememberWindowState(
    placement: WindowPlacement = WindowPlacement.Floating,
    isMinimized: Boolean = false,
    position: WindowPosition = WindowPosition.PlatformDefault,
    size: WindowSize
): WindowState

Creates a WindowState that is remembered across compositions.

Changes to the provided initial values will not result in the state being recreated or changed in any way if it has already been created.

Parameters
placement: WindowPlacement = WindowPlacement.Floating

the initial value for WindowState.placement

isMinimized: Boolean = false

the initial value for WindowState.isMinimized

position: WindowPosition = WindowPosition.PlatformDefault

the initial value for WindowState.position

size: WindowSize

the initial value for WindowState.size

rememberWindowState

@Composable
fun rememberWindowState(
    placement: WindowPlacement = WindowPlacement.Floating,
    isMinimized: Boolean = false,
    position: WindowPosition = WindowPosition.PlatformDefault,
    width: Dp = 800.dp,
    height: Dp = 600.dp
): WindowState

Creates a WindowState that is remembered across compositions.

Changes to the provided initial values will not result in the state being recreated or changed in any way if it has already been created.

Parameters
placement: WindowPlacement = WindowPlacement.Floating

the initial value for WindowState.placement

isMinimized: Boolean = false

the initial value for WindowState.isMinimized

position: WindowPosition = WindowPosition.PlatformDefault

the initial value for WindowState.position

width: Dp = 800.dp

the initial value for width of WindowState.size

height: Dp = 600.dp

the initial value for height of WindowState.size

singleWindowApplication

fun singleWindowApplication(
    state: WindowState = WindowState(),
    visible: Boolean = true,
    title: String = "Untitled",
    icon: Painter? = null,
    undecorated: Boolean = false,
    transparent: Boolean = false,
    resizable: Boolean = true,
    enabled: Boolean = true,
    focusable: Boolean = true,
    alwaysOnTop: Boolean = false,
    onPreviewKeyEvent: (KeyEvent) -> Boolean = { false },
    onKeyEvent: (KeyEvent) -> Boolean = { false },
    content: @Composable FrameWindowScope.() -> Unit
): Unit

An entry point for the Compose application with single window.

If you need to change attributes of the window in runtime, or need a custom closing logic, use Composable Window in application entry point instead:

application {
Window(...) { }
}
Parameters
state: WindowState = WindowState()

The state object to be used to control or observe the window's state When size/position/status is changed by the user, state will be updated. When size/position/status of the window is changed by the application (changing state), the native window will update its corresponding properties. If application changes, for example WindowState.placement, then after the next recomposition, WindowState.size will be changed to correspond the real size of the window. If WindowState.position is not WindowPosition.isSpecified, then after the first show on the screen WindowState.position will be set to the absolute values.

visible: Boolean = true

Is Window visible to user. If false:

  • internal state of Window is preserved and will be restored next time the window will be visible;

  • native resources will not be released. They will be released only when Window will leave the composition.

title: String = "Untitled"

Title in the titlebar of the window

icon: Painter? = null

Icon in the titlebar of the window (for platforms which support this). On macOs individual windows can't have a separate icon. To change the icon in the Dock, set it via iconFile in build.gradle (https://github.com/JetBrains/compose-jb/tree/master/tutorials/Native_distributions_and_local_execution#platform-specific-options)

undecorated: Boolean = false

Disables or enables decorations for this window.

transparent: Boolean = false

Disables or enables window transparency. Transparency should be set only if window is undecorated, otherwise an exception will be thrown.

resizable: Boolean = true

Can window be resized by the user (application still can resize the window changing state)

enabled: Boolean = true

Can window react to input events

focusable: Boolean = true

Can window receive focus

alwaysOnTop: Boolean = false

Should window always be on top of another windows

onPreviewKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. It gives ancestors of a focused component the chance to intercept a KeyEvent. Return true to stop propagation of this event. If you return false, the key event will be sent to this onPreviewKeyEvent's child. If none of the children consume the event, it will be sent back up to the root using the onKeyEvent callback.

onKeyEvent: (KeyEvent) -> Boolean = { false }

This callback is invoked when the user interacts with the hardware keyboard. While implementing this callback, return true to stop propagation of this event. If you return false, the key event will be sent to this onKeyEvent's parent.

content: @Composable FrameWindowScope.() -> Unit

Content of the window

Extension functions

MenuBar

@Composable
fun FrameWindowScope.MenuBar(content: @Composable MenuBarScope.() -> Unit): Unit

Composes menu bar on the top of the window

Parameters
content: @Composable MenuBarScope.() -> Unit

content of the menu bar (list of menus)

Tray

@Composable
fun ApplicationScope.Tray(
    icon: Painter,
    state: TrayState = rememberTrayState(),
    tooltip: String? = null,
    onAction: () -> Unit = {},
    menu: @Composable MenuScope.() -> Unit = {}
): Unit

Adds tray icon to the platform taskbar if it is supported.

If tray icon isn't supported by the platform, in the "standard" error output stream will be printed an error.

See isTraySupported to know if tray icon is supported (for example to show/hide an option in the application settings)

Parameters
icon: Painter

Icon of the tray

state: TrayState = rememberTrayState()

State to control tray and show notifications

tooltip: String? = null

Hint/tooltip that will be shown to the user

onAction: () -> Unit = {}

Action performed when user clicks on the tray icon (double click on Windows, right click on macOs)

menu: @Composable MenuScope.() -> Unit = {}

Context menu of the tray that will be shown to the user on the mouse click (right click on Windows, left click on macOs). If it doesn't contain any items then context menu will not be shown.

launchApplication

fun CoroutineScope.launchApplication(content: @Composable ApplicationScope.() -> Unit): Job

Short variant of launching application inside CoroutineScope.

This function is equivalent of:

CoroutineScope.launch {
awaitApplication {

}
}

Don't use GlobalScope.launchApplication {} to launch application inside main() function without waiting it to end. As it will not block the main thread, and application process will stop (because global coroutines are daemon threads, daemon threads don't keep process alive: https://kotlinlang.org/docs/coroutines-basics.html#global-coroutines-are-like-daemon-threads)

See also
awaitApplication

setContent

fun JMenuBar.setContent(
    parentComposition: CompositionContext,
    content: @Composable MenuBarScope.() -> Unit
): Composition

Composes the given composable into the MenuBar.

The new composition can be logically "linked" to an existing one, by providing a parentComposition. This will ensure that invalidations and CompositionLocals will flow through the two compositions as if they were not separate.

Parameters
parentComposition: CompositionContext

The parent composition reference to coordinate scheduling of composition updates. If null then default root composition will be used.

content: @Composable MenuBarScope.() -> Unit

Composable content of the MenuBar.

setContent

fun Menu.setContent(
    parentComposition: CompositionContext,
    content: @Composable MenuScope.() -> Unit
): Composition

Composes the given composable into the Menu.

The new composition can be logically "linked" to an existing one, by providing a parentComposition. This will ensure that invalidations and CompositionLocals will flow through the two compositions as if they were not separate.

Parameters
parentComposition: CompositionContext

The parent composition reference to coordinate scheduling of composition updates. If null then default root composition will be used.

content: @Composable MenuScope.() -> Unit

Composable content of the Menu.

setContent

fun JMenu.setContent(
    parentComposition: CompositionContext,
    content: @Composable MenuScope.() -> Unit
): Composition

Composes the given composable into the Menu.

The new composition can be logically "linked" to an existing one, by providing a parentComposition. This will ensure that invalidations and CompositionLocals will flow through the two compositions as if they were not separate.

Parameters
parentComposition: CompositionContext

The parent composition reference to coordinate scheduling of composition updates. If null then default root composition will be used.

content: @Composable MenuScope.() -> Unit

Composable content of the Menu.

Top-level properties

isTraySupported

val isTraySupportedBoolean

true if the platform supports tray icons in the taskbar