From 125cc7d477835309f7a065817bf8c32e9f6c6f28 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 5 Jun 2014 03:09:02 -0400 Subject: [PATCH] Figured out what happens if a message box is created for an invisible window, documented it was undefined (Windows and GTK+ behave reasonably but at least Windows is not documented here; Mac OS X shows a sheet attached to invisible where the titlebar should be and then considers the window closed), and added the panic() checks for uncreated Windows. --- dialog.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dialog.go b/dialog.go index 801d71d..2c16107 100644 --- a/dialog.go +++ b/dialog.go @@ -20,15 +20,20 @@ import ( // Attempts to interact with parent will be blocked, but all other Windows in the application can still be used properly. // The message box will also stay above parent. // As with parent == nil, resizing is implementation-defined, but will work properly if allowed. -// If parent has not yet been created, MsgBox() panics. [TODO check what happens if hidden] +// If parent has not yet been created, MsgBox() panics. +// If parent has not been shown yet or is currently hidden, what MsgBox() does is implementation-defined. func MsgBox(parent *Window, primaryText string, secondaryText string) { - // TODO implement panic after resolving above TODO + if parent != nil && !parent.created { + panic("parent window passed to MsgBox() before it was created") + } msgBox(parent, 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. func MsgBoxError(parent *Window, primaryText string, secondaryText string) { - // TODO impelment panic after resolving above TODO + if parent != nil && !parent.created { + panic("parent window passed to MsgBoxError() before it was created") + } msgBoxError(parent, primaryText, secondaryText) }