Neutron.ahk
Neutron.ahk copied to clipboard
Unable to destroy gui on <MyGui>Escape
I am fairly certain the syntax for destroying the gui on the press of the escape key is correct here, but it does not work. The form is properly destroyed when pressing the close button top right. Am I missing something here or is this a bug?
; Include the Neutron library
#Include ./libs/Neutron.ahk
MADRS(){
; Create a new NeutronWindow
Madrs := new NeutronWindow()
Madrs.Load("madrs-neutron.html")
Madrs.Gui("+LabelNeutron")
; Show the GUI
Madrs.Show("w1200 h1200 x2500 y500")
; Set focus to the form
Madrs.doc.focus()
WinActivate, % "madrs-neutron.ahk" Madrs.hWnd
return
MadrsEscape:
MsgBox, "escape pressed" ;this does not show
Madrs.Destroy() ;this does not destroy the gui
Return
MadrsClose:
Madrs.Destroy()
Return
}
Huge thanks for your work!!
The form is properly destroyed when pressing the close button top right
That's because the close button is calling the neutron.Close()
function which is set as its onclick
in the examples.
This should fix it :D
; Include the Neutron library
#Include ./libs/Neutron.ahk
MADRS(){
; Create a new NeutronWindow
global Madrs := new NeutronWindow() ; <---- the window object should be global, if you want to access it in the labels
Madrs.Load("madrs-neutron.html")
; Madrs.Gui("+LabelNeutron") ; <---- this should match the prefix you're using in the 'Close' and 'Escape' labels
Madrs.Gui("+LabelMadrs") ; like this
; Show the GUI
Madrs.Show("w1200 h1200 x2500 y500")
; Set focus to the form
Madrs.doc.focus()
WinActivate, % "madrs-neutron.ahk" Madrs.hWnd
return
MadrsEscape:
MsgBox, "escape pressed" ;this does not show
Madrs.Destroy() ;this does not destroy the gui
Return
MadrsClose:
Madrs.Destroy()
Return
}
Sorry for the late response, this works! Many thanks again! :D