-
I want to close Popup by Esc key, my code: package main
import (
"fmt"
"github.com/AllenDang/giu"
)
var close_popup bool
func loop() {
if close_popup {
close_popup = false
giu.CloseCurrentPopup()
}
giu.SingleWindow().Layout(
giu.PrepareMsgbox(),
giu.Row(
giu.PopupModal("MyPopup").Layout(
giu.Row(
giu.Button("ok").OnClick(giu.CloseCurrentPopup),
),
),
giu.Button(`MyPopup`).OnClick(func() { giu.OpenPopup("MyPopup") }),
giu.Custom(func() {
if close_popup { // not work
close_popup = false
giu.CloseCurrentPopup()
}
}),
),
)
}
func main() {
wnd := giu.NewMasterWindow("", 400, 300, 0).RegisterKeyboardShortcuts(
giu.WindowShortcut{
Key: giu.KeyEscape,
Callback: func() {
fmt.Println("esc pressed")
close_popup = true // not work
giu.CloseCurrentPopup() // not work
},
},
)
wnd.Run(loop)
} Click the button to open the popup, then press Esc, the Why is that ? |
Beta Was this translation helpful? Give feedback.
Answered by
AllenDang
Dec 13, 2021
Replies: 1 comment 1 reply
-
@aj3423 Move following lines into the g.PopupModal.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
aj3423
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@aj3423 Move following lines into the g.PopupModal.