gui/window: native open and save file dialogs
ShowFileDialog (UI thread) and ChooseFile (any goroutine, waits) show a native dialog for the window -- NSOpenPanel/NSSavePanel as a sheet on macOS, GetOpenFileNameW/GetSaveFileNameW on Windows -- with a title, a start folder, a suggested name and allowed extensions. It only returns the chosen path; one dialog at a time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e1495430c5
commit
5d141c7cef
7 files changed
+284
-2
No files matched your search
@@ -0,0 +1,22 @@
|
||||
//go:build windows
|
||||
|
||||
package window
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestFileFilter(t *testing.T) {
|
||||
raw := fileFilter([]string{"pdf", ".txt"})
|
||||
s := string(utf16Runes(raw))
|
||||
want := "*.pdf;*.txt (*.pdf;*.txt)\x00*.pdf;*.txt\x00All files (*.*)\x00*.*\x00\x00\x00"
|
||||
if s != want {
|
||||
t.Errorf("filter = %q, want %q", s, want)
|
||||
}
|
||||
}
|
||||
|
||||
func utf16Runes(u []uint16) []rune {
|
||||
r := make([]rune, len(u))
|
||||
for i, c := range u {
|
||||
r[i] = rune(c)
|
||||
}
|
||||
return r
|
||||
}
|
||||
Reference in new issue
Block a user