From 810eb18cd3d592672e36222f32721e5cbc195aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20N=C3=BCtzi?= Date: Thu, 11 Feb 2021 16:38:54 +0100 Subject: [PATCH] Handle close/cancel as unsuccesful --- dlgs_windows.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dlgs_windows.go b/dlgs_windows.go index 827608e..ca91536 100644 --- a/dlgs_windows.go +++ b/dlgs_windows.go @@ -520,6 +520,8 @@ func stringFromUtf16Ptr(p *uint16) string { // editBox displays textedit/inputbox dialog. func editBox(title, text, defaultText, className string, password bool) (string, bool, error) { var out string + notCancledOrClosed := true + var hwndEdit syscall.Handle instance, err := getModuleHandle() @@ -530,11 +532,13 @@ func editBox(title, text, defaultText, className string, password bool) (string, fn := func(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) uintptr { switch msg { case wmClose: + notCancledOrClosed = false destroyWindow(hwnd) case wmDestroy: postQuitMessage(0) case wmKeydown: if wparam == vkEscape { + notCancledOrClosed = false destroyWindow(hwnd) } case wmCommand: @@ -542,6 +546,7 @@ func editBox(title, text, defaultText, className string, password bool) (string, out = getWindowText(hwndEdit) destroyWindow(hwnd) } else if wparam == 110 { + notCancledOrClosed = false destroyWindow(hwnd) } default: @@ -589,5 +594,5 @@ func editBox(title, text, defaultText, className string, password bool) (string, return out, false, err } - return out, true, nil + return out, notCancledOrClosed, nil }