Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Engineering

Modified Events for Text Gadgets

  • Last UpdatedNov 14, 2022
  • 2 minute read

When you finish modifying the field by 'Tabbing' away or clicking another gadget or form the field content is validated. If a VALIDATE callback is assigned then it is executed and if no error results, then a SELECT event is raised. Otherwise an error is detected, the field’s background color becomes ‘gold’ and focus is returned to it for further modification.

The setEditable method allows PML to be notified when the displayed text is modified by user interaction:

setEditable( !attribute is STRING, !value is REAL )

Currently the only attribute supported is HANDLEMOIFY which may have the integer values:

  • 0 MODIFIED events off (default).

  • 1 Generate MODIFIED event at first user modification only.

  • 2 Generate MODIFIED event for all user modifications.

    Note:
    MODIFIED events are not notified to PML unless the field is editable, modified events are enabled and an open callback has been specified (so that MODIFIED and SELECT events cannot be differentiated)

Typically, the first MODIFIED event is used to allow AppWare to gain control and modify the properties (for example, ACTIVE status) of dependent gadgets, which possibly you should not have access to until the text field's VALIDATE and SELECT events have been handled.

The code fragment below defines an RTOGGLE that allows a user specified TV program to be typed into an associated TEXT gadget.

rToggle .rad6 tagwid 7 |TV:|                     States '' 'TV'

text .TV  width 10 is STRING

!this.rad6.callback = '!this.RGroupSelectionChanged('

-- set open callback on text field and option list

!this.TV.callback = '!this.selectProgram('

!this.Radio.callback = '!this.selectProgram('

‑ handle first Modified event only

!this.TV.setEditable( ‘handleModify’, 1 )

The extended (open) callback selectProgram(, shown below, intelligently handles the TEXT gadget and OPTION list. The open callback RGroupSelectionChanged sets the value of the 'TV' RTOGGLE from the TEXT gadget.

define method .selectProgram( !gad is GADGET, !event is STRING )

 -- Select new program from option list or text input field

 if( !gad.type( ) eq 'TEXT' ) then

  -- Control active state of R-toggle according to modified state of textfield

  !rtog = !this.rad6

  if( !event eq 'MODIFIED' ) then

   -- deactivate R-toggle

   !rtog.active = false

  elseif( !event eq 'SELECT' ) then

   -- reactivate R-toggle

   !rtog.active = true

  endif

 else

  -- select radio program from option list

  !rtog = !this.rad5

 endif

 if( !this.rg1.val eq !rtog.index ) then

  -- deselect current selection

  !this.rg1.val = 0

  !this.choice.clear()

 endif

endmethod

define method .RGroupSelectionChanged( !rtog is GADGET, !event is STRING )

 -- Service specified radio-toggle events

 if( !event eq 'UNSELECT' ) then

  -- Do some application actions

  !this.choice.clear()

 elseif( !event eq 'SELECT' ) then

  !value = !rtog.onValue

  -- Do some application actions

  if( !value eq 'radio' ) then

   !value = !this.Radio.selection('dtext')

  elseif( !value eq 'TV' ) then

   !value = !this.TV.val

  endif

  !this.choice.val = !value

 endif

endmethod

TitleResults for “How to create a CRG?”Also Available in