summaryrefslogtreecommitdiff
path: root/dialog.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-02 22:53:03 -0400
committerPietro Gagliardi <[email protected]>2014-07-02 22:53:03 -0400
commit8a81650b3da7ce00725336df9e03b38e935c5a65 (patch)
tree08af843f0460e7226f305cf7162021ef54e8c3f7 /dialog.go
parent4dd5ceb11d62bd6b9af4847936314a9d8c45707f (diff)
Moved it all back; the preemptive multitaksing during an event handler kills us on all platforms. Going to have to restrict ALL GUI accss to happening from one t hread, so going to need to drop uitask entirely and have just a start() callback for startup code and a post() function for posting requests to windows (like channel sends but into a perpetual buffer).
Diffstat (limited to 'dialog.go')
-rw-r--r--dialog.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/dialog.go b/dialog.go
new file mode 100644
index 0000000..6c62bfd
--- /dev/null
+++ b/dialog.go
@@ -0,0 +1,52 @@
+// 7 february 2014
+
+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.
+// primaryText should be a short string describing the message, and will be displayed with additional emphasis on platforms that support it.
+// Optionally, secondaryText can be used to show additional information.
+// If you pass an empty string for secondaryText, neither additional information nor space for additional information will be shown.
+// On platforms that allow for the message box window to have a title, os.Args[0] is used.
+//
+// See "On Dialogs" in the package overview for behavioral information.
+func MsgBox(primaryText string, secondaryText string) {
+ 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) {
+ if !w.created {
+ panic("parent window passed to Window.MsgBox() before it was created")
+ }
+ w.msgBox(primaryText, secondaryText)
+}
+
+// MsgBoxError displays a message box to the user with just an OK button and an icon indicating an error.
+// Otherwise, it behaves like MsgBox.
+//
+// See "On Dialogs" in the package overview for more information.
+func MsgBoxError(primaryText string, secondaryText string) {
+ 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) {
+ if !w.created {
+ panic("parent window passed to Window.MsgBox() before it was created")
+ }
+ w.msgBoxError(primaryText, secondaryText)
+}