This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v18
4D View Pro form events

4D View Pro form events  


 

The following form events are available in the Property List for 4D View Pro areas:

Some of the events are standard form events (available to all active objects) and some are specific 4D View Pro form events. The specific 4D View Pro form events provide additional information in the object returned by the FORM Event command when they are generated for 4D View Pro areas. The following table shows which events are standard and which are specif 4D View Pro form events:

 

Standard 4D events (see Form event code)Specific 4D View Pro events
On Load  On VP Ready
On Getting Focus On Clicked
On Losing Focus  On Double Clicked
On Unload  On Header Click
 On After Edit
 On Selection Change
 On Column Resize
 On Row Resize

Any 4D View Pro area initialization code, for loading or reading values from or in the area, must be located in the On VP Ready form event of the area. This form event is triggered once the area loading is complete. Testing this event makes you sure that the code will be executed in a valid context. An error is returned if a 4D View Pro command is called before the On VP Ready form event is generated.

Note: 4D View Pro areas are loaded asynchronously in 4D forms. It means that the standard On load form event cannot be used for 4D View Pro initialization code, since it could be executed before the loading of the area is complete. On VP Ready is always generated after On load.

Clicking anywhere on a 4D View Pro document generates the On Clicked event. The object returned by the FORM Event command contains:

 

PropertyTypeDescription
codelongintOn Clicked
descriptiontext"On Clicked"
objectNametext4D View Pro area name
sheetNametextName of the sheet of the event
rangeobjectCell range

 

Example:

 If(FORM Event.code=On Clicked)
    VP SET CELL STYLE(FORM Event.range;New object("backColor";"green"))
 End if

When a user double clicks anywhere on a 4D View Pro document, the On Double Clicked event is generated. The object returned by the FORM Event command contains:

 

PropertyTypeDescription
codelongintOn Double Clicked
descriptiontext"On Double Clicked"
objectNametext4D View Pro area name
sheetNametextName of the sheet of the event
rangeobjectCell range

 

Example:

 If(FORM Event.code=On Double Clicked)
    $value:=VP Get value(FORM Event.range)
 End if

A user clicking on a column or row header in a 4D View Pro document generates the On Header Click event. The object returned by the FORM Event command contains:

 

PropertyTypeDescription
codelongintOn Header Click
descriptiontext"On Header Click"
objectNametext4D View Pro area name
sheetNametextName of the sheet of the event
rangeobjectCell range
sheetArealongintThe sheet location where the event took place:
  • 0: The crossing area between column number/letter headers (top left of the sheet)
  • 1: The column headers (area indicating the column numbers/letters)
  • 2: The row headers (area indicating the row numbers)
  •  

    Example:

     If(FORM Event.code=On Header Click)
        Case of
           :(FORM Event.sheetArea=1)
              $values:=VP Get values(FORM Event.range)
           :(FORM Event.sheetArea=2)
              VP SET CELL STYLE(FORM Event.range;New object("backColor";"gray"))
           :(FORM Event.sheetArea=0)
              VP SET CELL STYLE(FORM Event.range;New object("borderBottom";New object("color";"#800080";"style";vk line style thick)))
        End case
     End if

    Following any user modification in a 4D View Pro document, the On After Edit event is generated. The object returned by the FORM Event command contains:

     

    PropertyTypeDescription
    codelongintOn After Edit
    descriptiontext"On After Edit"
    objectNametext4D View Pro area name
    sheetNametextName of the sheet of the event
    actiontext"editChange", "valueChanged", "DragDropBlock", "DragFillBlock", "formulaChanged", "clipboardPasted"

     

    Note: See also the On VP Range Changed event.

     

    Depending on the action property value, the object will contain additional properties.

    Editing text generates the following additional properties:

     

    PropertyTypeDescription
    rangeobjectCell range
    editingTextvariantThe value from the current editor

    Changing value(s) generates the following additional properties: 

     

    PropertyTypeDescription
    rangeobjectCell range
    oldValuevariantValue of cell before change
    newValuevariantValue of cell after change

    Dragging and dropping actions generate the inclusion of the following additional properties:

     

    PropertyTypeDescription
    fromRangeobjectRange of source cell range (being dragged)
    toRangeobjectRange of the destination cell range (drop location)
    copybooleanSpecifies if the source range is copied or not
    insertbooleanSpecifies if the source range is inserted or not

    Dragging content to fill adjacent cells generates the following additional properties:

     

    PropertyTypeDescription
    fillRangeobjectRange used for fill 
    autoFillTypelongintValue used for the fill. 
  • 0: Cells are filled with all data (values, formatting, and formulas)
  • 1: Cells are filled with automatically sequential data
  • 2: Cells are filled with formatting only
  • 3: Cells are filled with values but not formatting
  • 4: Values are removed from the cells
  • 5: Cells are filled automatically
  •  
    fillDirectionlongintDirection of the fill.
  • 0: The cells to the left are filled
  • 1: The cells to the right are filled
  • 2: The cells above are filled
  • 3: The cells below are filled
  • Entering formula(s) generates the following additional properties:

     

    PropertyTypeDescription
    rangeobjectCell range
    formulatextThe formula entered 

    Pasting content from the clipboard generates the following additional properties:

     

    PropertyTypeDescription
    rangeobjectCell range receiving the contents
    pasteOptionlongintSpecifies what is pasted from the clipboard:
  • 0: Everything is pasted (values, formatting, and formulas)
  • 1: Only values are pasted
  • 2: Only the formatting is pasted
  • 3: Only formulas are pasted
  • 4: Values and formatting are pasted (not formulas)
  • 5: Formulas and formatting are pasted (not values)
  • pasteDataobjectThe data from the clipboard to be pasted
     

     Property  Type  Description
    text  text The text from the clipboard
    html  text The HTML from the clipboard

    Example  

    Here is an example handling an On After Edit event:

     If(FORM Event.code=On After Edit)
        If(FORM Event.action="valueChanged")
           ALERT("WARNING: You are currently changing the value from "+String(FORM Event.oldValue)+" to "+String(FORM Event.newValue)+"!")
        End if
     End if

    The above example could generate an event object (see FORM Event) like this:


    {
    "code":45;
    "description":"On After Edit";
    "objectName":"ViewProArea"
    "sheetname":"Sheet1";
    "action":"valueChanged";
    "range": {area:ViewProArea,ranges:[{column:1,row:2,sheet:1}]};
    "oldValue":"The quick brown fox";
    "newValue":"jumped over the lazy dog";
    }

     

    Modification of the current selection of rows or columns in a 4D View Pro document generates the On Selection Change event. The object returned by the FORM Event command contains:

     

    PropertyTypeDescription
    codelongintOn Selection Change
    descriptiontext"On Selection Change"
    objectNametext4D View Pro area name
    sheetNametextName of the sheet of the event
    oldSelectionsobjectCell range before change. 
    newSelectionsobjectCell range after change.

     

    Example:

     If(FORM Event.code=On Selection Change)
        VP SET CELL STYLE(FORM Event.oldSelections;New object("backColor";Null))
        VP SET CELL STYLE(FORM Event.newSelections;New object("backColor";"red"))
     End if

    When a user modifies the width of a column in a 4D View Pro document, the On Column Resize event is generated. The object returned by the FORM Event command contains:

     

    PropertyTypeDescription
    codelongintOn Column Resize
    descriptiontext"On Column Resize"
    objectNametext4D View Pro area name
    sheetNametextName of the sheet of the event
    rangeobjectCell range of the columns whose widths have changed
    headerbooleanTrue if the row header column (first column) is resized, else false

     

    Example:

     If(FORM Event.code=On Column Resize)
        VP SET CELL STYLE(FORM Event.range;New object("hAlign";vk horizontal align right))
     End if

    A user modifying the height of a row in a 4D View Pro document generates the On Row Resize event. The object returned by the FORM Event command contains:

     

    PropertyTypeDescription
    codelongintOn Row Resize
    descriptiontext"On Row Resize"
    objectNametext4D View Pro area name
    sheetNametextName of the sheet of the event
    rangeobjectCell range of the rows whose heights have changed
    headerbooleanTrue if the column header row (first row) is resized, else false

     

    Example:

     If(FORM Event.code=On Row Resize)
        VP SET CELL STYLE(FORM Event.range;New object("vAlign";vk vertical align top))
     End if

     
    PROPERTIES 

    Product: 4D
    Theme: 4D View Pro form events

     
    PAGE CONTENTS 
     
    HISTORY 

     
    ARTICLE USAGE

    4D View Pro Reference ( 4D v18)