4D v15OBJECT GET COORDINATES |
||||||||||||||
|
4D v15
OBJECT GET COORDINATES
|
OBJECT GET COORDINATES ( {* ;} object ; left ; top ; right ; bottom ) |
||
Originally introduced in 4D v14 R5
Theme: Objects (Forms)
The OBJECT GET COORDINATES command can now return the coordinates of specific list box parts, i.e. columns, headers, or footers, and not just those of the list box parent object.
In previous releases, this command always returned the parent list box coordinates, regardless of the list box part it was applied to. Now, when the referenced object is a list box header, column, or footer sub-object, the coordinates returned are those of the designated list box sub-object.
You can use this new feature, for example, to display a small icon in the list box header cell when it is hovered over, which a user can then click to display a context menu.
Compatibility Note: If you are using this command on a list box header, footer, or column in your existing application, the coordinates returned will be different after conversion to 4D v14 R5 or higher. If you want to get the coordinates of the whole list box, you need to change the code so that the command is called on the list box object itself instead of a sub-object.
For consistency, the reference frame used is the same when the object is a list box sub-object or a list box object: the origin is the upper-left corner of the form which contains the object. For list box sub-objects, the coordinates returned are theoretical; they take into account the scrolling state of the list box before any clipping occurs. As a result, the sub-object may not be visible (or only partially so) at its coordinates, and these coordinates may be outside the form limits (or even negative). To find out whether the sub-object is visible (and which part of it is visible) you need to compare the coordinates returned with the list box coordinates, while considering the following rules:
For example, consider the following graphic where the coordinates of the Capital column are symbolized by the red rectangle:
As you can see in the first picture, the column is larger than the list box, so its coordinates go beyond the lower limit of the list box, including the footer. In the second picture, the list box has been scrolled, so the column has also been moved "under" the Language column and header area. In any case, in order to calculate the actual visible part (green area), you need to subtract the red areas.
For interface needs, you want to surround the clicked area with a red rectangle:
In the object method of the list box, you can write:
OBJECT SET VISIBLE(*;"rectangleInfo";False) //initialize a red rectangle
$ptr:=OBJECT Get pointer(Object current)
OBJECT GET COORDINATES($ptr->;$x1;$y1;$x2;$y2)
OBJECT SET VISIBLE(*;"RedRect";True)
OBJECT SET COORDINATES(*;"RedRect";$x1;$y1;$x2;$y2)
OBJECT GET COORDINATES(*;"LB1";$lbx1;$lby1;$lbx2;$lby2)
If($lby1>$y1)|($lby2<$y2) // if the clicked area is outside the listbox
OBJECT SET VISIBLE(*;"Alert";True) //display a warning
Else
OBJECT SET VISIBLE(*;"Alert";False)
End if
The method returns theoretical coordinates. In cases where the list box has been resized, you may need to calculate the clipping to know which part is visible:
Product: 4D
Theme: Language
4D v15 - Upgrade (standard edition) ( 4D v15)