^KeyStroke and ^DataChg

From BR Wiki
Jump to navigation Jump to search

As of 4.30, two new INPUT FIELDS field attributes are now supported which provide detailed control of user input:

  • ^KEYSTROKE - return control to the program when a keystroke is entered
  • ^DATACHG - return control to the program when data is changed

(a subset of ^KEYSTROKE)

When control is returned to a program as a result of these attributes, one of three new Fkey values is applied:

  • 140 - a character was appended to the data
  • 141 - the data changed other than appending a character
  • 142 - ( applies only to ^KEYSTROKE ) the data is unchanged but a key was pressed or a mouse action occurred that did not trigger a field exit

When a key is pressed with ^KEYSTROKE or ^DATACHG that sets a 140, 141 or 142 FKEY, it will also set the KStat$ value. This allows the program to see what key was pressed. This KSTAT$ value will be cleared on the next RINPUT Fields operation.

If a navigation key operates within the field and ^KEYSTROKE is specified, it triggers fkey 142. If the navigation key causes focus to leave the field, fkeys 140-142 are not generated and KSTAT is not set.

Sample

00001   PRINT Newpage
00010   INPUT FIELDS "10,10,C 10,[D]S^DataCHGC"&Str$(New_Pos),ATTR '[A]': Dummy$
00020   PRINT FIELDS "1,70,n 10": Fkey
00025   LET New_Field$=Kstat$
00026   LET New_Pos=Curpos
00030   PRINT FIELDS "3,70,N 10": New_Pos
00040   PRINT FIELDS "4,70,C 10": Unhex$(New_Field$)&" "&New_Field$
00050   PRINT FIELDS "5,70,C 10": Dummy$
00090   LET Curfld(Curfld,Fkey) !:
        GOTO 10

The program triggers ^DATACHG and displays the FKEY along with the value that was pushed to KSTAT$. Each keystrokeis processed. The input allows granular control.

Note

While shift, control and alt do not change either the functionality or fkey value of navigation keys, KSTAT$ produces unique values for each of these settings. This complicates things a bit but provides more options for programmed responses to custom key combinations.