diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-26 12:52:32 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-26 12:52:32 -0400 |
| commit | adbe5303e7d97e439e1f1f75df23d357b037f702 (patch) | |
| tree | a9bafa99c1def93cae7afc54c3f2679445b3c0f5 /redo/dialog.go | |
| parent | e7490ce49b113f4d1877de8f5ee4b40b183fbabf (diff) | |
Changed the way dialogs work so that they do real modality properly and implemented such on Windows.
Diffstat (limited to 'redo/dialog.go')
| -rw-r--r-- | redo/dialog.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/redo/dialog.go b/redo/dialog.go index 877ccf2..1567cc7 100644 --- a/redo/dialog.go +++ b/redo/dialog.go @@ -2,10 +2,19 @@ package ui +type windowDialog interface { + openFile(f func(filename string)) +} + // OpenFile opens a dialog box that asks the user to choose a file. -// It returns the selected filename, or an empty string if no file was chosen. -// All events stop while OpenFile is executing. (TODO move to doc.go) +// The dialog box is modal to win, which mut not be nil. +// Some time after the dialog box is closed, OpenFile runs f on the main thread, passing filename. +// filename is the selected filename, or an empty string if no file was chosen. +// OpenFile does not ensure that f remains alive; the programmer is responsible for this. // If possible on a given system, OpenFile() will not dereference links; it will return the link file itself. -func OpenFile() (filename string) { - return openFile() +func OpenFile(win Window, f func(filename string)) { + if win == nil { + panic("Window passed to OpenFile() cannot be nil") + } + win.openFile(f) } |
