Delta Pythagorean wrote:Interesting, but I still prefer using the function inside a method. Do you know anyway of doing this?
If a label does not exist for a given event, a function with that name can be called instead.
So I guess you cannot do this (strictly within the field of the built-in GUI command, at least). If you still want to use a method you must have an incentive to do so. In particular, if the goal is to avoid to populate the global scope, a half-baked solution could be to specify a custom prefix for you GUI labels. Actually, further in the documentation on can read:
[...] To set a custom prefix, use Gui +Label.
So you can also do this:
Code: Select all
G1 := new GUI_(), G2 := new GUI_()
return
Class GUI_ {
__New() {
local __hwnd
MsgBox, 64,, % A_ThisFunc
Gui, New, % "+Resize +Hwnd__hwnd +Label" . this.__class . "On"
Gui, %__hwnd%:Add, Edit, x0 y0 vEdit
Gui, %__hwnd%:Show, w800 h500
this.GuiSize()
}
GuiSize() {
MsgBox, 64,, % A_ThisFunc
}
}
GUI_OnSize(__hwnd, __eventInfo, __width, __height) {
ToolTip % __hwnd " " __eventInfo " " __width " " __height
}
So that you reserve the variable name
GUI_* in your script. See also
this other solution by
GeekDude - not sure to fully understand how it works exactly, though. Note that it still uses functions, and, I would be tempted to say , if even
GeekDude uses function, it is likely that there's no alternative:
Yes it is possible to to this:
Code: Select all
f()g()
f() {
MsgBox % A_ThisFunc
}g() {
MsgBox % A_ThisFunc
}