From 46578847cba0ad11a4d95e3e69de498cb93dc6cf Mon Sep 17 00:00:00 2001 From: pj Date: Wed, 24 Jan 2018 19:21:05 +1100 Subject: [PATCH] Added alert dialog --- dialog.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/dialog.go b/dialog.go index 33701eb..7ea5e50 100644 --- a/dialog.go +++ b/dialog.go @@ -31,7 +31,15 @@ type SelectDialog struct { onClose func() } -// NewConfirmationDialog creates new confirmation dialog. +// CreateAlertDialog creates a new alert dialog. +// title is a dialog title +// message is a text inside dialog for user to be notified of a fact +// button is a title for button inside dialog. +func CreateAlertDialog(title, message string, button string) *ConfirmationDialog { + return CreateConfirmationDialog(title, message, []string{button}, 0) +} + +// CreateConfirmationDialog creates new confirmation dialog. // c is a composer that manages the dialog // title is a dialog title // question is a text inside dialog for user to explain what happens @@ -103,12 +111,12 @@ func CreateConfirmationDialog(title, question string, buttons []string, defaultB CreateFrame(frm1, 1, 1, BorderNone, 1) if defaultButton == DialogButton2 && len(buttons) > 1 { - ActivateControl(dlg.view, btn2) + ActivateControl(dlg.view, btn2) } else if defaultButton == DialogButton3 && len(buttons) > 2 { - ActivateControl(dlg.view, btn3) - } else { + ActivateControl(dlg.view, btn3) + } else { ActivateControl(dlg.view, btn1) - } + } dlg.view.OnClose(func(ev Event) bool { if dlg.result == DialogAlive {