Gui_Close not functioning correctly
Issue #18
closed
This code works in v2.0-beta.7:
myGui := Gui()
myGui.AddText("", "Press Alt+F4 or the X button in the title bar.")
myGui.OnEvent("Close", myGui_Close)
myGui_Close(thisGui) { ; Declaring this parameter is optional.
if MsgBox("Are you sure you want to close the GUI?",, "y/n") = "No"
return True ; true = 1
}
myGui.Show()
All my attempts to get this to work in keysharp have been without success. Here is one attempt:
myGui := Gui()
myGui.AddText("", "Press Alt+F4 or the X button in the title bar.")
myGui.OnEvent("Close", "myGui_Close")
myGui_Close(thisGui) { ; Declaring this parameter is optional.
if (MsgBox("Are you sure you want to close the GUI?",, 4) == "No")
return True ; true = 1
}
myGui.Show()
My attempt solved a failure to honor “y/n” (trivial), but I’m unsure where to go next. It appears a Keysharp MsgBox with this option (Yes/No) returns a string “Yes” or a string “No.”, but I tried the following returns (and several others) without luck:
if (MsgBox("Are you sure you want to close the GUI?",, 4) == "No")
return("No")
if (MsgBox("Are you sure you want to close the GUI?",, 4) == "No")
return(1)
Comments (5)
-
reporter -
repo owner Fix committed. You can use “y/n”, as you observed it was a casing issue.
Also, the return value is properly observed to prevent closing the window when clicking no.
Please test.
-
reporter Tested following code, works fine, please mark resolved and closed. Thanks!
myGui := Gui() myGui.AddText("", "Press Alt+F4 or the X button in the title bar.") myGui.OnEvent("Close", "myGui_Close") myGui_Close() { if (MsgBox("Are you sure you want to close the GUI?",, 4) == "No") return True } myGui.Show()
-
repo owner - changed status to resolved
-
repo owner - changed status to closed
- Log in to comment
Looking at the Keysharp code, I can fix the “y/n” issue by changing it to uppercase as well as using '4'.