Response Inquiry Built-in Functions
Return positional change values for the most recent window event.
{xdelta|ydelta}
Description
Window events occur when window attributes are selected to modify a window. Window events are triggered by the following window commands: close, restore, size, move, maximize, minimize, vertical scroll, and horizontal scroll. Since the delta values are updated each time a window event on clause is executed, xdelta and ydelta allow you to determine the change in the size, position, or scroll units after an on resize, on move, on maximize, on vscroll, or on hscroll clause is executed. (In certain cases, on restore also affects xdelta and ydelta.)
The following table shows the change value that xdelta and ydelta will contain following execution of the different on clauses.
on Clause |
xdelta Contains |
ydelta Contains |
on resize |
Change in object's xsize |
Change in object's ysize |
on move |
Change in object's xposition |
Change in object's yposition |
on hscroll |
Change in the horizontal scroll |
0 |
on vscroll |
0 |
Change in the vertical scroll |
on maximize* |
Change in size of the object |
Change in size of the object |
on restore* |
Size change in restoring the region |
Size change in restoring the region |
* After an on maximize or on restore response that restores a minimized region, both xdelta and ydelta return 0.
Delta Units
The xdelta and ydelta built-in functions always return values in the same units as the modified object. These units vary depending on the window event and the object type.
If an object is vertically scrolled, the following rules apply:
For graphical, image, and sense regions, the window position xdelta and ydelta are expressed in device units.
For dialog regions, xdelta and ydelta are expressed in dialog units.
For textual regions, xdelta and ydelta are expressed in lines (vertical scroll) and columns (horizontal scroll).
For dialog controls (except tables), ydelta is expressed in lines, since they deal with the scrolling of text. on hscroll is not supported for controls, so xdelta always returns 0 in these cases.
For tables, xdelta is expressed in columns and ydelta is expressed in rows.
In addition, scroll units can be specified in the definition of objects, so you can limit the xdelta and ydelta values returned. For example, if you set scroll units 5 for an object, xdelta and ydelta always return a multiple of five.
If an object is resized, xdelta and ydelta follow the same rules, with the exception of textual regions, which return columns and lines if the region was defined using window size; otherwise, they return device units.
If an object is moved, xdelta and ydelta always return the device units of the object's parent, consistent with the existing built-in functions xposition and yposition.
Example
response to Object1_TR
on size
change Object2_TR size by xdelta ydelta
on move
change Object2_TR position by xdelta ydelta
on hscroll
change Object2_TR window position by xdelta ydelta
# ydelta will be 0 since this is a horizontal scroll
on vscroll
change Object2_TR window position by xdelta ydelta
# xdelta will be 0 since this is a vertical scroll
See Also
response Definition
xposition and yposition Object Inquiry Built-in Functions