-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Call system Explorer/Finder to select files in Compose #176
Comments
We can use java.awt.FileDialog:
|
Thanks! |
Figured I would post what I did to have file open files using the menu bar / keyboard shortcuts in case anyone else arrived here looking to do the same thing
and that eventually leads to
|
No longer seems to be available; this is what worked for me: Button(onClick = {
java.awt.FileDialog(AppManager.focusedWindow!!.window).isVisible = true
}) {
Text("File Picker")
} |
It was renamed to LocalAppWindow (I changed my comment). Better to use it instead of focusedWindow. focusedWindow works, but probably not in all cases (we can "click" without taking the window into focus, for example in tests) |
Updated:
|
If I'm not mistaken, @igordmn it seems |
We should pass the parent window instead of the new Window (so the parent window will be blocked while dialog is opened). In 1.0 we can do that this way:
There is also |
awesome, thanks for the quick reply! A small detail I noticed is, you need to actually use Anyway, also thanks for the pointer to the Composable way, that's sounds like it is the way one really wants to integrate this. |
Good point, thanks. I changed the comment. |
I can't select a dir in this way |
wow, indeed, looks like val f = JFileChooser()
f.fileSelectionMode = JFileChooser.DIRECTORIES_ONLY
f.showSaveDialog(null) |
probably worth a separate issue |
To get a native look and feel (tested on Windows) I called this at the start of the program: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) To open directories only, created and showed a dialog like this: val fileChooser = JFileChooser("/").apply {
fileSelectionMode = JFileChooser.DIRECTORIES_ONLY
dialogTitle = "Select a folder"
approveButtonText = "Select"
approveButtonToolTipText = "Select current directory as save destination"
}
fileChooser.showOpenDialog(window.window /* OR null */)
val result = fileChooser.selectedFile |
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks. |
How does that achievable?
The text was updated successfully, but these errors were encountered: