summaryrefslogtreecommitdiff
path: root/dialog.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-30 22:48:12 -0400
committerPietro Gagliardi <[email protected]>2014-06-30 22:48:12 -0400
commitffa1bbe0b91a8c812ddcea5c5d65e55f60d07f33 (patch)
tree000fadd9af11843d92e7f0eee49fa90cca1379cd /dialog.go
parent990d50e9a153681a091a23734f8962e728fde1b0 (diff)
Restored the previous new API. I'm going to change it so that events are callbacks rather than using a window handler, but other than that... yeah.
Diffstat (limited to 'dialog.go')
-rw-r--r--dialog.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/dialog.go b/dialog.go
index 9c2ad2c..6c62bfd 100644
--- a/dialog.go
+++ b/dialog.go
@@ -2,8 +2,16 @@
package ui
+// Response denotes a response from the user to a Dialog.
+type Response uint
+const (
+ NotDone Response = iota
+ OK
+)
+
// sentinel (not nil so programmer errors don't go undetected)
// this window is invalid and cannot be used directly
+// notice the support it uses
var dialogWindow = new(Window)
// MsgBox displays an informational message box to the user with just an OK button.
@@ -14,16 +22,16 @@ var dialogWindow = new(Window)
//
// See "On Dialogs" in the package overview for behavioral information.
func MsgBox(primaryText string, secondaryText string) {
- <-dialogWindow.msgBox(primaryText, secondaryText)
+ dialogWindow.msgBox(primaryText, secondaryText)
}
// MsgBox is the Window method version of the package-scope function MsgBox.
// See that function's documentation and "On Dialogs" in the package overview for more information.
-func (w *Window) MsgBox(primaryText string, secondaryText string) (done chan struct{}) {
+func (w *Window) MsgBox(primaryText string, secondaryText string) {
if !w.created {
panic("parent window passed to Window.MsgBox() before it was created")
}
- return w.msgBox(primaryText, secondaryText)
+ w.msgBox(primaryText, secondaryText)
}
// MsgBoxError displays a message box to the user with just an OK button and an icon indicating an error.
@@ -31,14 +39,14 @@ func (w *Window) MsgBox(primaryText string, secondaryText string) (done chan str
//
// See "On Dialogs" in the package overview for more information.
func MsgBoxError(primaryText string, secondaryText string) {
- <-dialogWindow.msgBoxError(primaryText, secondaryText)
+ dialogWindow.msgBoxError(primaryText, secondaryText)
}
// MsgBoxError is the Window method version of the package-scope function MsgBoxError.
// See that function's documentation and "On Dialogs" in the package overview for more information.
-func (w *Window) MsgBoxError(primaryText string, secondaryText string) (done chan struct{}) {
+func (w *Window) MsgBoxError(primaryText string, secondaryText string) {
if !w.created {
- panic("parent window passed to MsgBoxError() before it was created")
+ panic("parent window passed to Window.MsgBox() before it was created")
}
- return w.msgBoxError(primaryText, secondaryText)
+ w.msgBoxError(primaryText, secondaryText)
}