From 06ad6eb8a1fda64feffe10e7b248c0b4f74ffce7 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Thu, 5 Nov 2020 10:57:51 -0400 Subject: [PATCH] update ShowAlert optimize return code --- README.md | 2 +- README_zh.md | 2 +- examples/window/main.go | 2 +- robotgo.go | 4 ++-- test/main.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 28b8dda..9d5ef10 100644 --- a/README.md +++ b/README.md @@ -311,7 +311,7 @@ func main() { } abool := robotgo.ShowAlert("test", "robotgo") - if abool == 0 { + if abool { fmt.Println("ok@@@ ", "ok") } diff --git a/README_zh.md b/README_zh.md index 42378a1..760990b 100644 --- a/README_zh.md +++ b/README_zh.md @@ -308,7 +308,7 @@ func main() { } abool := robotgo.ShowAlert("test", "robotgo") - if abool == 0 { + if abool { fmt.Println("ok@@@ ", "ok") } diff --git a/examples/window/main.go b/examples/window/main.go index b953629..fb8bbb1 100644 --- a/examples/window/main.go +++ b/examples/window/main.go @@ -20,7 +20,7 @@ import ( func alert() { // show Alert Window abool := robotgo.ShowAlert("hello", "robotgo") - if abool == 0 { + if abool { fmt.Println("ok@@@", "ok") } robotgo.ShowAlert("hello", "robotgo", "Ok", "Cancel") diff --git a/robotgo.go b/robotgo.go index 99128cc..7adf936 100644 --- a/robotgo.go +++ b/robotgo.go @@ -1361,7 +1361,7 @@ ____ __ ____ __ .__ __. _______ ______ ____ __ ____ */ // ShowAlert show a alert window -func ShowAlert(title, msg string, args ...string) int { +func ShowAlert(title, msg string, args ...string) bool { var ( // title string // msg string @@ -1392,7 +1392,7 @@ func ShowAlert(title, msg string, args ...string) int { C.free(unsafe.Pointer(adefaultButton)) C.free(unsafe.Pointer(acancelButton)) - return ibool + return ibool == 0 } // IsValid valid the window diff --git a/test/main.go b/test/main.go index 2666411..30e8406 100644 --- a/test/main.go +++ b/test/main.go @@ -19,7 +19,7 @@ import ( func aRobotgo() { abool := robotgo.ShowAlert("test", "robotgo") - if abool == 0 { + if abool { fmt.Println("ok@@@", "ok") }