[Gambas-user] equivalent python self
Jean-Yves F. Barbier
12ukwn at ...626...
Sun Aug 16 17:48:18 CEST 2009
Doriano Blengino a écrit :
...
>> i.e.:
>> TreeView1_MouseDown()
>> TextBox2756.Text = "xxxxxxx"
>> LAST.Enable = TRUE => does it apply to TreeView1 or TextBox2756 ?
>> END
>>
> applies to TreeView1 -------------^
>
> I see your ideas are not clear. In the above subroutine LAST refers to
> the object which raised the event - presumably TreeView1 when you
> pressed a mouse button on it. But you can make several objects call the
> same event handler:
>
> ANewButton = new Button(me) as "TreeView1" ' just to explain...
>
> After that declaration, if you click that button, TreeView1_MouseDown
> will be called, and the same will happen if you click on TreeView1 (two
> different objects call the same event handler). But in the first case
> LAST will refer to ANewButton, in the second it will refer to TreeView1.
> That's all - no other meanings can be attached to LAST, and its life
> ceases when the subroutine (i.e., event handler) ceases. LAST is a
> global variable, so gambas will let you access it even when such a thing
> would be wrong; it makes sense only when referring to "the object which
> raised this singular event I am managing now".
Thanks Doriano it is now clear; so I'll stick to real name to avoid any side
effect.
JY
--
It is far better to sleep with an old hen than pullet.
More information about the User
mailing list