In previous 4D versions, the scrolling of picture variables and fields could be handled through the On Picture Scroll form event (value 59).
In 4D v15, the handling of this kind of event has been extended to list box objects (see below). Consequently, the On Picture Scroll form event has been renamed On Scroll and is now also available for list boxes in the Property list. The action of this event on pictures remains unchanged.
Compatibility Notes:
There are two small differences between the On Picture Scroll form event implementation in previous versions of 4D and the new On Scroll implementation:
- On Picture Scroll was generated in the object method and in the form method (but it cannot be checked or unchecked at the form property level). For better consistency, starting with 4D v15, the On Scroll event is generated only in the object method. If your converted application was handling picture scrolling events from the form method, you will need to move the code to the appropriate object method.
- In the event stack, On Picture Scroll could be called before other user events such as On Click. On Scroll is always generated after the other user events.
In 4D v15, the On Scroll event is available for two scrollable objects:
- Picture fields and variables with the "Truncated (non centered)" format (already available in previous 4D versions under the On Picture Scroll name),
- List boxes (new in 4D v15).
By default, the event is not checked for objects in the Property list.
The On Scroll form event is generated as soon as a user scrolls the form object within the area that contains it. The event is only generated when the scroll is the result of a user action: using the scroll bars and/or cursors, using the mouse wheel or the keyboard. It is not generated when the object is scrolled due to the execution of the OBJECT SET SCROLL POSITION command.
This event is triggered after any other user event related to the scrolling action (On Clicked, On After Keystroke, etc.).
The event is only generated in the object method (not in the form method).
You want to draw a red rectangle around the selected cell of a list box, and you want the rectangle to move along with the list box if it is scrolled vertically by the user. In the list box object method, you can write:
As a result, the red rectangle follows the scrolling of the list box:
