I am trying to use the androidx.compose.ui.window.MenuBar
from
It only offers me to import from those 2 locations but when I use the import it does not complain or resolve the error.
build.gradle.kts
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.6.10"
id("org.jetbrains.compose") version "1.1.0"
}
group = "me.whate"
version = "1.0"
repositories {
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
dependencies {
implementation(compose.desktop.currentOs)
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "11"
}
compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "Test"
packageVersion = "1.0.0"
}
}
}
I have tried to invalidate caches, etc but no success so far.
Anybody has any suggestion?
CodePudding user response:
You have to modify it like this:
@OptIn(ExperimentalComposeUiApi::class)
fun main() = application {
Window(onCloseRequest = ::exitApplication) {
var text by remember { mutableStateOf("Hello, World!") }
DesktopMaterialTheme {
MenuBar {
// your menubar code here
}
Button(onClick = {
text = "Hello, Desktop!"
}) {
Text(text)
}
}
}
}
and completely remove the App() function