JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.88k stars 1.15k forks source link

menubar Can I hide it macOS #4068

Open Xiaolangs opened 8 months ago

Xiaolangs commented 8 months ago

1703498919996 menubar Can I hide it

lizhongyue248 commented 7 months ago

I have found a solution and hope it can help you.

This is my old code

fun main = aoplication {
    DialogWindow() {
        // ...
    }
}

And add a Property apple.awt.UIElement

fun main() {
    System.setProperty("apple.awt.UIElement", "true");
    aoplication {
        DialogWindow() {
            // ...
        }
    }
}

This will treat the application as a UI element and no longer display menubar.

But I only tested DialogWindow without testing Window. You can try it based on your application, hoping it can help you

dima-avdeev-jb commented 7 months ago

This issue have a very interesting behavior what maybe usefull in current issue: https://github.com/JetBrains/compose-multiplatform/issues/4114

lizhongyue248 commented 7 months ago

Another solution is to add the configuration to InfoPlist during the construction of macos

      macOS {
        iconFile.set(project.file("icon/mac.icns"))
        infoPlist {
          extraKeysRawXml = """
                        <key>LSUIElement</key>
                        <string>true</string>
                        <key>LSBackgroundOnly</key>
                        <string>true</string>
                    """.trimIndent()
        }
      }
okushnikov commented 2 weeks ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.