File tree Expand file tree Collapse file tree
demo/src/jvmMain/kotlin/com/kdroid/composetray/demo Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -646,6 +646,48 @@ trayAppState.setWindowSize(400.dp, 600.dp)
646646trayAppState.setWindowSize(DpSize (350 .dp, 500 .dp))
647647```
648648
649+ ## 🧩 New: Tray Window Dismiss Modes
650+
651+ By default, the ` TrayApp ` popup window closes automatically when it loses focus or when the user clicks outside of it.
652+ With the new ` TrayWindowDismissMode ` API, you can choose between:
653+
654+ * ** AUTO** (default): The popup closes automatically when focus is lost or when clicking outside.
655+ * ** MANUAL** : The popup remains visible until you explicitly call ` trayAppState.hide() ` .
656+
657+ ### Example
658+
659+ ``` kotlin
660+ @OptIn(ExperimentalTrayAppApi ::class )
661+ application {
662+ val trayAppState = rememberTrayAppState(
663+ initialWindowSize = DpSize (300 .dp, 400 .dp),
664+ initiallyVisible = false ,
665+ initialDismissMode = TrayWindowDismissMode .MANUAL // 👈 Manual mode
666+ )
667+
668+ TrayApp (
669+ state = trayAppState,
670+ icon = Icons .Default .Settings ,
671+ tooltip = " Quick Settings"
672+ ) {
673+ Column {
674+ Text (" This popup will NOT auto-close" )
675+ Button (onClick = { trayAppState.hide() }) {
676+ Text (" Close manually" )
677+ }
678+ }
679+ }
680+ }
681+ ```
682+
683+ ### Switching at runtime
684+
685+ ``` kotlin
686+ LaunchedEffect (Unit ) {
687+ trayAppState.setDismissMode(TrayWindowDismissMode .AUTO )
688+ }
689+ ```
690+
649691### Advanced Examples
650692
651693#### Example 1: Control from Main Window
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ fun main() {
4343 val trayAppState = rememberTrayAppState(
4444 initialWindowSize = DpSize (300 .dp, 500 .dp),
4545 initiallyVisible = true ,
46- initialDismissMode = TrayWindowDismissMode .MANUAL
46+ initialDismissMode = TrayWindowDismissMode .AUTO
4747 )
4848
4949 // Observe visibility changes
You can’t perform that action at this time.
0 commit comments