Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unresolved reference: ExposedDropdownMenuBox in Compose for Desktop

I need to implement a drop down menu for Windows App which is based on Compose for Desktop
For that I am trying to use ExposedDropdownMenuBox

But I am getting error:

Unresolved reference: ExposedDropdownMenuBox

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Following is the code:

ExposedDropdownMenuBox(
    expanded = expanded,
    onExpandedChange = {
        expanded = !expanded
    }
) {
    // TextFeild implementation
}

And the file build.gradle.kts contains following:

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.1"
}

group = "com.op.bgmi"
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 = "App"
            packageVersion = "1.0.0"
        }
    }
}

Am I missing something, please advice.
What is the correct approach to have drop down menu box in Compose for Desktop

>Solution :

ExposedDropdownMenuBox is currently not available for Desktop.

You can check the location of the item in the AndroidX repository: it is located in androidMain folder, which makes it only available for the Android platform. It uses some Android-specific APIs under the hood, which makes it impossible to use from the desktop.

Perhaps it will be rewritten and made cross-platform before the `Experimental’ annotation is removed, or there will be a separate implementation for Desktop in the future. You can follow updates here.

For now, you can use DropdownMenu as shown in this answer.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading