Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

on macOS cannot choose json file #43

Open
tangshimin opened this issue Sep 6, 2023 · 5 comments
Open

on macOS cannot choose json file #43

tangshimin opened this issue Sep 6, 2023 · 5 comments

Comments

@tangshimin
Copy link

tangshimin commented Sep 6, 2023

version: v2.0.2
operating system: macOS Monterey v12.6.1
JDK: IBM OpenJ9, version: 17.0.8

demo:

import androidx.compose.foundation.layout.Column
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import com.darkrockstudios.libraries.mpfilepicker.FilePicker


fun main() = application {
    var show1 by remember { mutableStateOf(false) }
    var show2 by remember { mutableStateOf(false) }
    var pathChosen1 by remember { mutableStateOf("") }
    var pathChosen2 by remember { mutableStateOf("") }


    Window(onCloseRequest = ::exitApplication) {
        Column {
            Button(onClick = {
                show1 = true
            }) {
                Text("Choose File 1")
            }
            Text("File Chosen 1: $pathChosen1")

            /////////////////////////////////////////////////////////////////
            Button(onClick = {
                show2 = true
            }) {
                Text("Choose File 2")
            }
            Text("File Chosen 2: $pathChosen2")

        }

        // if set one json file extension, cannot choose json files
        FilePicker(show1, fileExtensions = listOf("json")) { file ->
            pathChosen1 = file?.path ?: "none selected"
            show1 = false
        }
        // if set multiple file extensions, can choose json files
        FilePicker(show2, fileExtensions = listOf("json", "txt")) { file ->
            pathChosen2 = file?.path ?: "none selected"
            show2 = false
        }
    }

}
@shalva97
Copy link
Collaborator

shalva97 commented Sep 6, 2023

It is a JVM variant, right?

@tangshimin
Copy link
Author

tangshimin commented Sep 6, 2023

yes, I use IBM OpenJ9, version: 17.0.8

@tangshimin
Copy link
Author



If the fileExtensions is set to json and another arbitrary file extension, it seems that you can choose any type of file



        FilePicker(show2, fileExtensions = listOf("json", "txt")) { file ->
            pathChosen2 = file?.path ?: "none selected"
            show2 = false
        }


@shalva97
Copy link
Collaborator

shalva97 commented Sep 6, 2023

okay, I have asked it here LWJGL/lwjgl3#921, now we wait for them

@naijun0403
Copy link

These issues seem to apply to TOML files as well, not just JSON.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants