KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using ON EVENT CALL to Manage Page Up and Down
PRODUCT: 4D | VERSION: 11.5 | PLATFORM: Mac & Win
Published On: March 15, 2010

The keystrokes PageUp and PageDown cannot be handled with regular 4D Form events. To respond to them you need to implement the ON EVENT CALL command. A good example of a time you might want to do this is in List Boxes. If the user scrolls the List Box up or down you might want to highlight a new record or load new records into the selection. Some sample code for handling this is shown below:

This code would be used in the List Box object's method:

Case of
  : (Form event=On Getting Focus )
    ON EVENT CALL("eventmethod")
  : (Form event=On Losing Focus )
    ON EVENT CALL("")
End case


It is important to remember to turn the On Getting Focus and On Losing Focus form events on for this object. This code sets the Project Method eventmethod to be called in case of any event that would normally trigger ON EVENT CALL. Then we need to handle the events PageUp and PageDown in that method. Here is some sample code used in it:

  `eventmethod Project Method

C_LONGINT($key)
$key:=KeyCode
Case of
  : ($key=11)
    `insert code here to handle PageUp
  : ($key=12)
    `insert code here to handle PageDown
End case