With (GuiObject).OnEvent "Close",ExitApp
I get an error message:
Parameter #1 of ExitApp requires a Number, but received a Gui.
010: txt.SetFont("s22 cnavy bold","Times New Roman")
012: win.Show("w500 h200")
013: Exit
ExitApp is a built-in function which on the docs say the callback can be a built-in.
Using fat arrow (GuiObject).OnEvent "Close",(*)=>ExitApp works without errors.
Even without a Close OnEvent my Gui closes. WHY?
With (GuiObject).OnEvent "Escape",(*)=>ExitApp not working, no error message.
What am I missing, thanks for any info on this issue.
My testing Gui:
Code: Select all
win := Gui(,"Test OnEvent Status")
win.BackColor := "Blue"
;win.OnEvent "Close",ExitApp ;THIS IS NOT WORKING WITH ERROR MSG
;win.OnEvent "Close",(*)=>ExitApp ;THIS WORKS
win.OnEvent "Escape",(*)=>ExitApp ;THIS IS NOT WORKING
txt := win.AddText("center x50 y50 w400 h100 BackgroundAqua",Format("AHK Version={}`nOS Version={}`n{}",A_AhkVersion,A_OSVersion,(A_PtrSize=8?" 64Bit":" 32Bit")))
txt.SetFont "s22 cnavy bold","Times New Roman"
win.Show "w500 h200"
;Esc::ExitApp ;THIS WORKS