What can be Me in a Method’s Window

  1. last week

    Emile S

    Dec 4 Europe (France, Strasbourg)

    I had a long standing bug in an image resizing method (in a window).

    Sometimes, I get an eye on this kind of code hoping to discover “why the bug”…

    And minutes ago, I was asking myself what that Me.Height could be in a Method.

    I looked carefully and think that Me refers to a Canvas, and replaced me with the Canvas reference.

    All of a sudden, the bug disappears.

    After some minutes (doing something else), I realized that the Method where the bug resides before its removal probably was in that Canvas long time ago.

    For some unknow reason, the linker / compiler / whatever (Xojo) was not complaining about it before I changed the code.

    But my question remains: what Me refers to in a Method ?

    For Info: that line of code was used to center the resized image in the Canvas (the X value of the g.DrawPicture call).
    And, yes, now the image is centered and the real bug is squashed. (the image appears regardless of its original size)…

  2. Jean-Yves P

    Dec 4 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

    me or self refers to the window if it is in a window's method.
    me refers to a control if it is in a control event
    self refers to the window or container control surrounding the control in a control event.

  3. Emile S

    Dec 4 Europe (France, Strasbourg)

    @Jean-YvesPochez me or self refers to the window if it is in a window's method.

    Thats it !

    The image was a bit too to the right - and the Canvas have 20 (left) and 20 (Right) pixels for margins… and is now correctle centered…

    Thank you Jean-Yves.

  4. Ulrich B

    Dec 5 Pre-Release Testers, Xojo Pro Europe (Germany, Berlin) · xo...

    You can get some reassurance by hovering with the mouse over the "me" in the code editor. The description line will show the class of "me".

  5. Emile S

    Dec 5 Europe (France, Strasbourg)

    You are correct Ulrich !

    But the main problem (for me and in this case) was to realize there is a Me in a Method here…

or Sign Up to reply!