DefineProp() and DefineMethod()
Posted: 15 May 2023, 07:48
by madsounds
In AHK 2.0.2, how to add new property to the String class?
How to add new method to any class, since there's no more DefineMethod method>
Re: DefineProp() and DefineMethod() Topic is solved
Posted: 15 May 2023, 09:40
by teadrinker
madsounds wrote: ↑how to add new property to the String class?
Adding Properties and Methods
madsounds wrote: ↑How to add new method to any class
Code: Select all
class MyClass {
}
MyClass.DefineProp('NewMethod', {Call: (this, params*) => MsgBox(params[1])})
MyClass.NewMethod('test')
MyClass.DefineProp('AnotherMethod', {Call: myFunc})
MsgBox MyClass.AnotherMethod('a', 'b', 'c')
myFunc(this, params*) {
s := ''
for param in params
s .= param . ' '
return s
}
Re: DefineProp() and DefineMethod()
Posted: 15 May 2023, 11:37
by madsounds
Thank you!!!