milan jurkulák 2 lat temu
rodzic
commit
f2c5a98530

+ 1 - 0
src/main/kotlin/eu/mjdev/desktop/Main.kt

@@ -30,6 +30,7 @@ fun main() = application(
                 menuState = menuState
             ) {
                 DesktopPanel(
+                    menuState = menuState,
                     panelState = panelState,
                     onMenuIconClicked = {
                         menuState.toggle()

+ 2 - 1
src/main/kotlin/eu/mjdev/desktop/components/appsmenu/AppsMenu.kt

@@ -49,7 +49,8 @@ fun AppsMenu(
     position = WindowPosition.Absolute(
         panelState.bounds.x,
         api.containerSize.height - (panelState.bounds.height + appMenuMinHeight)
-    )
+    ),
+    onFocusChange = { focus -> if (!focus) menuState.hide() }
 ) {
     Box(
         modifier = Modifier

+ 2 - 1
src/main/kotlin/eu/mjdev/desktop/components/controlcenter/ControlCenter.kt

@@ -56,7 +56,8 @@ fun ControlCenter(
         DpSize(controlCenterExpandedWidth, api.containerSize.height)
     } else {
         DpSize(controlCenterDividerWidth, api.containerSize.height)
-    }
+    },
+    onFocusChange = { focus -> if (!focus) controlCenterState.hide() }
 ) {
     SlidingMenu(
         modifier = Modifier.fillMaxHeight(),

+ 3 - 2
src/main/kotlin/eu/mjdev/desktop/components/desktoppanel/DesktopPanel.kt

@@ -53,7 +53,7 @@ fun DesktopPanel(
     panelState: VisibilityState = rememberVisibilityState(),
     enterAnimation: EnterTransition = fadeIn() + slideInVertically(initialOffsetY = { it }),
     exitAnimation: ExitTransition = slideOutVertically(targetOffsetY = { it }) + fadeOut(),
-
+    menuState: VisibilityState = rememberVisibilityState(),
     tooltipData: MutableState<Any?> = mutableStateOf(null),
     onTooltip: (item: Any?) -> Unit = { item -> tooltipData.value = item },
     panelHeight: (visible: Boolean) -> Dp = { visible ->
@@ -68,7 +68,8 @@ fun DesktopPanel(
     size = DpSize(
         api.containerSize.width,
         panelHeight(panelState.isVisible)
-    )
+    ),
+    onFocusChange = { focus -> if (!focus && !menuState.isVisible) panelState.hide() }
 ) {
     SlidingMenu(
         modifier = Modifier.fillMaxWidth(),