Subject |
Re: Entryfield does not recognise the Enter Key |
From |
Mervyn Bick <invalid@invalid.invalid> |
Date |
Mon, 30 Jan 2023 09:54:30 +0200 |
Newsgroups |
dbase.getting-started |
Attachment(s) |
key_test.wfm |
On 2023/01/30 07:51, Michael wrote:
> Hi Lee,
>
> I believe you are on the right track, I remember reading somewhere about a bug on the entryfield object. It doesnt matter whether CUAENTER is on or off, it simply is not picking up the char parameter with a value if enter is pressed. Worked perfectly with visual Dbase 7.5 but something sets it off in Dbase 11 which is what I use.
>
> Even a very simple form with just a table and entryfield to onclick a pushbutton once a barcode is scanned or even if enter is pressed on a keyboard it still doesnt work. Can you confirm if this is the problem with Dbase 11?
We need to see example code. The attached example returns identical
results in dBASE 10, dBASE 11, dBASE 12 and dBASE 2019 under Windows 10
Pro, 64-bit, version 22H2.
The example shows that, provided CUAENTER is set ON, both the key and
onKey event handlers for an entryfield return 13 in the nChar parameter
of the event handler when the Enter key is pressed. The entryfield
must, of course, have focus.
When CUAENTER is set OFF the nChar parameter in the event handlers
returns 9 when the Enter key is pressed. This is WAD.
If you want pressing the Enter key to move focus to the next object in
the z-order even though CUAENTER is ON you can keyboard TAB to the
entryfield. You will need to un-comment the relevant line in the
example. In this case will see that the entryfield's onKey event
handler is fired twice so if you are using the onKey event handler to
execute code you will need to deal with this.
Mervyn.
| ** END HEADER -- do not remove this line
//
// Generated on 2023-01-26
//
parameter bModal
local f
f = new key_testForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class key_testForm of FORM
with (this)
onOpen = class::FORM_ONOPEN
onClose = class::FORM_ONCLOSE
height = 16.0
left = 19.0
top = 2.9091
width = 40.0
text = ""
endwith
this.ENTRYFIELD1 = new ENTRYFIELD(this)
with (this.ENTRYFIELD1)
key = class::ENTRYFIELD1_KEY
onKey = class::ENTRYFIELD1_ONKEY
height = 1.0
left = 8.2857
top = 1.6818
width = 8.0
value = ""
endwith
this.RADIOBUTTON1 = new RADIOBUTTON(this)
with (this.RADIOBUTTON1)
onChange = class::RADIOBUTTON1_ONCHANGE
height = 1.0909
left = 8.2857
top = 9.2727
width = 15.7143
text = "cuaenter ON"
group = true
value = true
endwith
this.RADIOBUTTON2 = new RADIOBUTTON(this)
with (this.RADIOBUTTON2)
height = 1.0909
left = 8.2857
top = 11.0909
width = 15.7143
text = "cuaenter OFF"
endwith
function ENTRYFIELD1_key(nChar, nPosition,bShift,bControl)
?'Key',this.name,nchar
if set('cuaenter') = 'ON' and nChar = 13
// this.keyboard('{tab}')
endif
return
function ENTRYFIELD1_onKey(nChar, nPosition,bShift,bControl)
? 'onKey',this.name,nchar
return
function RADIOBUTTON1_onChange()
if form.radiobutton1.value = true
set cuaenter on
else
set cuaenter off
endif
return
function form_onClose()
cCuaenter = form.cuaenter
set cuaenter &cCuaenter
return
function form_onOpen()
clear
form.cuaenter = set('cuaenter')
return
endclass
|
|