Handle close/cancel as unsuccesful
This commit is contained in:
parent
566c40cbe8
commit
810eb18cd3
1 changed files with 6 additions and 1 deletions
|
@ -520,6 +520,8 @@ func stringFromUtf16Ptr(p *uint16) string {
|
||||||
// editBox displays textedit/inputbox dialog.
|
// editBox displays textedit/inputbox dialog.
|
||||||
func editBox(title, text, defaultText, className string, password bool) (string, bool, error) {
|
func editBox(title, text, defaultText, className string, password bool) (string, bool, error) {
|
||||||
var out string
|
var out string
|
||||||
|
notCancledOrClosed := true
|
||||||
|
|
||||||
var hwndEdit syscall.Handle
|
var hwndEdit syscall.Handle
|
||||||
|
|
||||||
instance, err := getModuleHandle()
|
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 {
|
fn := func(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) uintptr {
|
||||||
switch msg {
|
switch msg {
|
||||||
case wmClose:
|
case wmClose:
|
||||||
|
notCancledOrClosed = false
|
||||||
destroyWindow(hwnd)
|
destroyWindow(hwnd)
|
||||||
case wmDestroy:
|
case wmDestroy:
|
||||||
postQuitMessage(0)
|
postQuitMessage(0)
|
||||||
case wmKeydown:
|
case wmKeydown:
|
||||||
if wparam == vkEscape {
|
if wparam == vkEscape {
|
||||||
|
notCancledOrClosed = false
|
||||||
destroyWindow(hwnd)
|
destroyWindow(hwnd)
|
||||||
}
|
}
|
||||||
case wmCommand:
|
case wmCommand:
|
||||||
|
@ -542,6 +546,7 @@ func editBox(title, text, defaultText, className string, password bool) (string,
|
||||||
out = getWindowText(hwndEdit)
|
out = getWindowText(hwndEdit)
|
||||||
destroyWindow(hwnd)
|
destroyWindow(hwnd)
|
||||||
} else if wparam == 110 {
|
} else if wparam == 110 {
|
||||||
|
notCancledOrClosed = false
|
||||||
destroyWindow(hwnd)
|
destroyWindow(hwnd)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -589,5 +594,5 @@ func editBox(title, text, defaultText, className string, password bool) (string,
|
||||||
return out, false, err
|
return out, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return out, true, nil
|
return out, notCancledOrClosed, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue