[beginner] x,y coordinates in LiveCode

Richard Gaskin ambassador at fourthworld.com
Sat Jan 10 12:50:38 EST 2015


Shawn Bl wrote:

> I'm trying to find the x,y coordinates with a mouse hover to find the
> location of buttons on my card.
>
> Perhaps a little stack or something.  Trying to create a menu and need to
> the x,y coordinates for several buttons.

Like most languages, LiveCode provides a way to express the bounding 
rectangle of an object, as well as its location.

But it may be helpful to note that these values may be different from 
what you'll find in other languages.

For example, in JavaScript/CSS, the order of rectangle coordinates is:

    top, right, bottom, left

...but in LiveCode (and other xTalks) the order is:

    left, top, right, bottom

Also, in some other languages the location property is a pair of 
coordinates expressing the top-left of the object, but in xTalks like 
LiveCode the location is the centerpoint of the object.  Thankfully both 
languages use the same order for points, x,y.

Possibly beyond the scope of your interest, if you're coming from a CSS 
background it can be helpful to remember that the margin property in LC 
is the opposite how it's used in CSS: in CSS the margin defines the area 
outside of the control's border, but in LiveCode is defines the boundary 
within the border (such as the space between the edge of a field and the 
text within it).

In LiveCode you can observe and modify the size and location properties 
of selected controls with the "Size and Position" pane of the Inspector.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list