4D v15

On Scroll form event

Home

 
4D v15
On Scroll form event

On Scroll form event  


 

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).

Example  

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:

 Case of
 
    :(Form event=On Clicked)
       LISTBOX GET CELL POSITION(*;"LB1";$col;$raw)
       LISTBOX GET CELL COORDINATES(*;"LB1";$col;$raw;$x1;$y1;$x2;$y2)
       OBJECT SET VISIBLE(*;"RedRect";True//initialize a red rectangle
       OBJECT SET COORDINATES(*;"RedRect";$x1;$y1;$x2;$y2)
 
    :(Form event=On Scroll)
       LISTBOX GET CELL POSITION(*;"LB1";$col;$raw)
       LISTBOX GET CELL COORDINATES(*;"LB1";$col;$raw;$x1;$y1;$x2;$y2)
       OBJECT GET COORDINATES(*;"LB1";$xlb1;$ylb1;$xlb2;$ylb2)
       $toAdd:=LISTBOX Get headers height(*;"LB1") //height of the header so as not to overlap it
       If($ylb1+$toAdd<$y1) & ($ylb2>$y2//if we are inside the list box
  //to keep it simple, we only handle headers
  //but we should handle horizontal clipping
  //as well as scroll bars
          OBJECT SET VISIBLE(*;"RedRect";True)
          OBJECT SET COORDINATES(*;"RedRect";$x1;$y1;$x2;$y2)
       Else
          OBJECT SET VISIBLE(*;"RedRect";False)
       End if
 
 End case

As a result, the red rectangle follows the scrolling of the list box:

 
PROPERTIES 

Product: 4D
Theme: Language

 
HISTORY 

 
TAGS 

.

 
ARTICLE USAGE

4D v15 - Upgrade (standard edition) ( 4D v15)

Inherited from : On Scroll form event ( 4D v15)