2014-02-17 01:34:58 -06:00
// 7 february 2014
2014-03-12 20:55:45 -05:00
2014-02-19 10:41:10 -06:00
package ui
2014-02-17 01:34:58 -06:00
import (
2014-03-12 11:14:24 -05:00
// ...
2014-02-17 01:34:58 -06:00
)
2014-06-08 07:17:47 -05:00
// sentinel (presently nil; may be a private instance if subtle bugs start showing up in user code)
var dialogWindow * Window
2014-02-17 01:34:58 -06:00
// MsgBox displays an informational message box to the user with just an OK button.
2014-03-12 11:14:24 -05:00
// primaryText should be a short string describing the message, and will be displayed with additional emphasis on platforms that support it.
2014-04-10 11:34:30 -05:00
// 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.
2014-03-12 11:14:24 -05:00
// On platforms that allow for the message box window to have a title, os.Args[0] is used.
2014-06-04 22:12:56 -05:00
//
2014-06-08 07:17:47 -05:00
// The message box is modal to the entire application: the user cannot interact with any other window until this one is dismissed.
2014-06-04 22:12:56 -05:00
// Whether or not resizing Windows will still be allowed is implementation-defined; if the implementation does allow it, resizes will still work properly.
// Whether or not the message box stays above all other W+indows in the program is also implementation-defined.
2014-06-08 07:17:47 -05:00
func MsgBox ( primaryText string , secondaryText string ) {
2014-06-08 07:50:52 -05:00
<- dialogWindow . msgBox ( primaryText , secondaryText )
2014-06-08 07:17:47 -05:00
}
// MsgBox behaves like the package-scope MsgBox function, except the message box is modal to w only.
// Attempts to interact with w will be blocked, but all other Windows in the application can still be used properly.
// The message box will also stay above w.
// Whether w can be resized while the message box is displayed is implementation-defined, but will work properly if allowed.
// If w has not yet been created, MsgBox() panics.
// If w has not been shown yet or is currently hidden, what MsgBox does is implementation-defined.
2014-06-08 07:50:52 -05:00
//
// On return, done will be a channel that is pulsed when the message box is dismissed.
func ( w * Window ) MsgBox ( primaryText string , secondaryText string ) ( done chan struct { } ) {
2014-06-08 07:17:47 -05:00
if ! w . created {
panic ( "parent window passed to Window.MsgBox() before it was created" )
2014-06-05 02:09:02 -05:00
}
2014-06-08 07:50:52 -05:00
return w . msgBox ( primaryText , secondaryText )
2014-02-17 01:34:58 -06:00
}
// MsgBoxError displays a message box to the user with just an OK button and an icon indicating an error.
2014-03-12 11:14:24 -05:00
// Otherwise, it behaves like MsgBox.
2014-06-08 07:17:47 -05:00
func MsgBoxError ( primaryText string , secondaryText string ) {
2014-06-08 07:50:52 -05:00
<- dialogWindow . msgBoxError ( primaryText , secondaryText )
2014-06-08 07:17:47 -05:00
}
// MsgBoxError displays a message box to the user with just an OK button and an icon indicating an error.
// Otherwise, it behaves like Window.MsgBox.
2014-06-08 07:50:52 -05:00
func ( w * Window ) MsgBoxError ( primaryText string , secondaryText string ) ( done chan struct { } ) {
2014-06-08 07:17:47 -05:00
if ! w . created {
2014-06-05 02:09:02 -05:00
panic ( "parent window passed to MsgBoxError() before it was created" )
}
2014-06-08 07:50:52 -05:00
return w . msgBoxError ( primaryText , secondaryText )
2014-02-17 01:34:58 -06:00
}