DR ON EVENT

4D - Documentation   Français   English   German   4D Draw 2004, Command Theme List   4D Draw 2004, Command Alphabetical List   Back   Previous   Next

version 6.0


DR ON EVENT (method)

ParameterTypeDescription
methodTextMethod to execute

Description

The command DR ON EVENT executes method whenever a previously specified event occurs.

The events that cause method to execute are described by the DR EVENT FILTER command. If method is an empty string, no method is executed. If the area in which the event occurs has both an object method and an event method, the object method executes last. DR ON EVENT is especially useful for 4D Draw areas in external windows because they cannot have object methods.

When 4D Draw calls method, it returns four parameters ($1, $2, $3, and $4) that can be used to manage the event.

$1 is a long integer that represents the 4D Draw area where the event took place.

$2 is an integer that holds the event code. $2 is the equivalent of a call to DR Last event.

$3 is the table number of the form on which the area resides. If $3 equals -1, the area is in an external window.

$4 is the number of the field into which the area is being autosaved. If $4 equals 0, the area is not being autosaved.

See Appendix C, Event Codes, for a complete list of event codes.

You should declare the types of these parameters in the event method if you plan to compile your database, as follows:

   C_LONGINT ($1;$2;$3;$4)

Example

The following example shows the installation of an event method. It opens an external window, specifies Command-click (Ctrl-click on Windows) as the event and then installs the event method, EventProc.

      `Open external window
   vArea := Open external window (20;50;400;350;0;"Draw";"_4D DRAW")   
   DR ON EVENT ("EventProc")
      `Install the method EventProc
   DR EVENT FILTER (vArea;64)
      `Command-Click will call the method

The following method is EventProc. It checks to see how many objects are selected, and if there is only one, displays the object's current name in a request dialog box to allow the user to change it.

   C_LONGINT ($1;$2;$3;$4)
   If (DR Count (VArea) # 1)
         `More or less than one object selected
      ALERT ("Select only one object!")
         `Alert the user
   Else 
      $Name := DR Get name (vArea;0)
         `Get the name of the selected object
      $Name := Request ("Object name…";$Name)
         `Allow user to specify new name
      If (OK = 1)
            `If the user accepted the request
         DR SET NAME (vArea;0;$Name)
            `Set the new name
      End if 
   End if 

See Also

DR EVENT FILTER, DR Last event.


4D - Documentation   Français   English   German   4D Draw 2004, Command Theme List   4D Draw 2004, Command Alphabetical List   Back   Previous   Next