Subject Re: Entryfield does not recognise the Enter Key
From Mervyn Bick <invalid@invalid.invalid>
Date Thu, 26 Jan 2023 10:49:38 +0200
Newsgroups dbase.getting-started

On 2023/01/26 01:07, Michael wrote:
> Hi Guys,
>
> I have an unusual problem. I have an entryfield that for some reason wont recognise the enter key.
>
> If CUAENTER is off then pressing enter jumps to the next field. In either case enter is not recognised in the nchar value of the entryfield key method.
......
> Anyone have this problem in the past?


If CUAENTER is ON (the preferred default setting) an entryfield's key
(or onKey) event handler returns 13 to nChar when the Enter key is
pressed and 9 when the Tab key is pressed.  The Tab key causes focus to
move to the next control in the z-order.  Pressing the Enter key leaves
focus on the entryfield.  Your key event handler will trap the Enter
press and execute the onClick event handler for pushbuton1.

If CUAENTER is OFF an entryfield's key (or onKey) event handler returns
9 to nChar when either the Enter key or the Tab key is pressed.
Pressing either key causes focus to move to the next key in the z-order.
The onClick event handler for pushbutton1 will not be executed.

If you really need to have CUAENTER OFF so that both the Enter key and
the Tab key force focus to move to the next control you can try testing
for both nChar = 9 and nChar = 13


    function ENTRYFIELD1_key(nChar, nPosition,bShift,bControl)
       If nChar = 13 or nChar = 9
          FORM.PUSHBUTTON1.ONCLICK()                
       ENDIF        
       return

If this causes problems with your barcode reader then set CUAENTER ON
and emulate CUAENTER OFF by keybaording a TAB press when the Enter key
is pressed.  This will, of course, need to be implemented for all entry
fields.  A custom entryfield would be the way to go.

   function ENTRYFIELD1_key(nChar, nPosition,bShift,bControl)
       If nChar = 13
          FORM.PUSHBUTTON1.ONCLICK()        
         this.keyboard('{tab}') // Move focus        
       ENDIF
       return

You can check the default setting for CUAENTER on your computer by
typing ? set('cuaenter') in the Command Panel when you open dBASE.

If the default setting for CUAENTER is OFF you can change it back to ON
by selecting Properties -> Desktop Properties from the menu and
selecting the Data Entry tab.  If the Data Entry tab is not visible use
the arrow buttons next to the tabs to bring it to view.  Tick the
CUAENTER box and save.

Mervyn.