Setting the location of controls

Peter Haworth pete at mollysrevenge.com
Wed Feb 9 17:11:58 CST 2011


Continuing to work on dragging controls from a palette to another stack.  I have everything working as I want it to except for an anomaly when the control is a datagrid. 

For all controls except a datagrid, the control is created with it's top left corner exactly at the mouse location at dragEnd.  For a datagrid, it's not close. I've tried to figure out a relationship between the loc points and the actual top and left of the dragged datagrid but I can't find one.  The code for setting the loc is the same no matter whether it's a datagrid or any other type of control.  

In trying to figure this out, I've been looking at the dictionary entries for dragMove and location.  

The dictionary entry for dragMove shows no parameters but the code I got from Richard has a dragMove handler that shows 2 parameters, x and y.   What are these parameters?  Are they the location of the mouse pointer or are they the distance from the top and left of the screen/window to the centre of the dragImage?  If the latter, the positioning of the datagrid would make sense.  For all the controls except the datagrid, the image I drag is the same size as the control itself; for a datagrid, the image is a different size than the datagrid that is created

The above is all based on the dictionary entry for location which says that, for controls on a card, the first value is the number of pixels from the left edge of the card to the centre of the object and the second is the number of pixels from the top of the card to the centre of the object.  

Pete Haworth











More information about the use-livecode mailing list