Code: Select all
MyGuiObj := MyGUIClass.New()
class MyGUIClass
{
__new() {
this.MyGui := Gui.New()
this.MyEdit := this.MyGui.Add("Edit")
this.MyEdit.OnEvent('Change', 'mycallback')
this.MyGui.Show()
}
}
mycallback(GuiCtrlObj, Info){
SoundBeep
}
ObjBindMethod builds a reference to mycallback in this.
Code: Select all
MyGuiObj := MyGUIClass.New()
class MyGUIClass
{
__new() {
this.MyGui := Gui.New()
this.MyEdit := this.MyGui.Add("Edit")
this.MyEdit.OnEvent('Change', ObjBindMethod(this,'mycallback'))
this.MyGui.Show()
}
mycallback(GuiCtrlObj, Info){
SoundBeep
}
}
You should notice that MyGuiObj is not a Gui. It's just a class contening a Gui in this.MyGui.
If you use
class MyGUIClass extends Gui, then MyGUIClass is a Gui.
Code: Select all
MyGuiObj := MyGUIClass.New()
class MyGUIClass extends Gui
{
__New() {
super.__New(, , this)
this.Add('Edit').OnEvent('Change', 'mycallback')
this.Show()
}
mycallback(GuiCtrlObj, Info){
SoundBeep
}
}
When you call this.Show(), witch doesn't exists in MyGUIClass, it calls Gui.Show()
But:
You can't call this.__New(… from inside __New( itself because it will loop ! So you call super.__New(… to specificaly call Gui.__New(.
When you give the argument this in
super.__New(, , this) you say:
Events named in OnEvent(… are all in this. So you don't need to use ObjBindMethod(this,'mycallback').
mycallback should better be named Edit_Change.
If you come back here, you should declare this topic solved by swagfag.