4D View v16

PV ON EVENT

Home

 
4D View v16
PV ON EVENT

PV ON EVENT 


 

PV ON EVENT ( area ; event ; method ) 
Parameter Type   Description
area  Longint in 4D View area
event  Longint in 4D View event
method  String in Method name

The PV ON EVENT command is used to link a method to a 4D View event. Every time event occurs, the method is executed.

The PV Event constants are used to define the event parameter.

The called method receives 6 Longint parameters and returns a Boolean in $0:

$1: The 4D View area reference
$2: The event
$3: Key modification code
$4: The column number
$5: The row number
$6: Ascii code of the key (if the event is a click, a right click or a double click, $6 is set to 0)

$3 can be set to one of the following values (these values are added if a key combination is pressed):

0None
512 Shift key
2048Alt key
4096Ctrl key (Windows) / Command key (Mac OS).
  • Click management (pv on clicked, pv on right clicked, pv on double clicked and pv on contextual click events):
    - If the event (click, right click, double click or contextual click) happens in a cell, $4 returns the column number and $5 returns the row number. If it happens on a row header, $4 is set to 0. If it happens on a column header, $5 is set to 0. If it happens in the upper left corner of the area, $4 and $5 are set to 0.
    - The pv on contextual click event is called when the user releases the mouse button; whereas the pv on right clicked event is called when the button is pressed. These two events can be used to put an interface using pop-up context menus into place. The pv on contextual click event corresponds more with Windows operation and the pv on right clicked event with that of Mac OS. The two events can be used simultaneously.
    - If the event is a click, a right click, a double click or a contextual click, $6 is set to 0.
  • Change of selection (pv on selection changed event):
    - If the new selection includes several cells, columns or rows, $4 and $5 return 0.
    - If the new selection includes a single cell, $4 and $5 return the column and row number of the cell, respectively.
    - If the new selection is a column, $4 returns the column number and $5 returns 0.
    - If the new selection is a row, $4 returns 0 and $5 returns the row number.
  • Function keys: in the context of a pv on keyboard event, if a function key has been enabled, the parameter $6 returns 0. In this case, use the 4D Keycode system variable to find out the ASCII code of the enabled function key.
  • Sort: The pv on column sort event is generated just after a column has been sorted. This way, it can be used to control user actions. In this case, $6 receives a value indicating the sort order. This value can be compared with the following constants, located in the PV Header sort theme:
    Constant Type Value Comment
    pv ascending sort Longint 2 4D View carries out ascending sort.
    pv descending sort Longint 3 4D View carries out descending sort.
  • Resizing: The pv on column resize and pv on row resize events are sent when a column or row is resized by the user. They are not sent if the columns or rows are resized by programming (using the PV SET COLUMNS WIDTH or PV SET ROWS HEIGHT commands).

If $0 is True, the event will not be taken into account.
If $0 is False, the event will be taken into account.

Note: If you intend to compile your database, you must declare $0 as Boolean and $1 to $6 as Longints even if some of them are not used.

If area is equal to 0, the PV ON EVENT command will be applied to all new 4D View areas. In this case, it is better to pass this command in the On Startup Database Method, which is executed when the database is opened.

To uninstall the on event method, simply call the PV ON EVENT command with an empty string in the last parameter.

The user clicks on the column header to carry out a sort. The PM_Event method is used to find out which column has been sorted and in what order.

  //Installation of the method that will be called during the pv on column sort event:
 PV ON EVENT(area;pv on column sort;"PM_Event")
 
  //PM_Event method
 C_BOOLEAN($0)
 C_LONGINT($1;$2;$3;$4;$5;$6)
 C_TEXT($SortOrder)
 If($2=pv on column sort)
    Case of
       :($6=pv ascending sort)
          $SortOrder:="ascending"
       :($6=pv descending sort)
          $SortOrder:="descending"
    End case
    ALERT("The sort was carried out on the column "+String($4)+" in "+$SortOrder)
 End if

A double-click on a column header causes the column to be resized. However, a double-click generates a sequence of two events: pv on clicked then pv on double clicked.
As a result, if sorting has been allowed by a call to PV SET AREA PROPERTY, a double-click on a header first causes the sorting of the column, then its resizing. If you want a double-click to only cause resizing of the column, you must intercept and remove the pv on clicked event, which is generated just before the sort is carried out. To do this, simply install a method that will be called during the pv on clicked event:

  `Installation of the method that will be called during the pv on clicked event
 PV ON EVENT(area;pv on clicked;"PM_Event")
 
  `PM_Event method
 C_BOOLEAN($0)
 C_LONGINT($1;$2;$3;$4;$5;$6)
 If($2=pv on clicked)
    $0:=True `The event is ignored and the sort is not carried out
 End if



See also 

PV Get on event method

 
PROPERTIES 

Product: 4D View
Theme: PV Area
Number: 15994

 
HISTORY 

Modified: 4D View 2004.1

 
ARTICLE USAGE

4D View Language ( 4D View v16)