1. [WIN] determining key press

Hi, all.

I'm having trouble understanding how to determine (via Win32lib)
whether the Enter key was pressed.  I've read the docs in 
Win32lib.ew re: onKeyDown and found them to be unintelligible (to me).
Also, have found no examples of using onKeyDown in any of the 
sample programs.

My need occurs in a program with a number of EditText fields. If the
user inadvertantly presses the enter key instead of tabbing to the next
fields, the program assumes data entry is finished, and then proceeds 
to try to process without the required data, and crashes. I'd like to be 
able to trap the pressing of the Enter key, and just setFocus to the 
next EditText field if that event occured. 

After a long, sleepless night trying to solve this, I must turn, once
again to my knowledgeable mentors. Any help will be gratefully 
received. 

Thanks.
Josh

new topic     » topic index » view message » categorize

2. Re: [WIN] determining key press

Joshua,

See if this works for you, it took just minutes using Judith's IDE!!  :)

Dan Moyer

<tested code follows:>
--  code generated by Win32Lib IDE v0.10.5

include Win32Lib.ew
without warning

----------------------------------------------------------------------------
----
--  Window Window1
global constant Window1 = create( Window, "Window1", 0, Default, Default,
400, 300, 0 )
global constant EditText2 = create( EditText, "EditText2", Window1, 20, 24,
50, 20, 0 )
global constant EditText3 = create( EditText, "EditText3", Window1, 128, 28,
50, 20, 0 )
global constant EditText4 = create( EditText, "EditText4", Window1, 240, 36,
50, 20, 0 )
----
procedure EditText2_onKeyPress ( int keyCode, int shift )
if keyCode = 13  then
    setFocus( EditText3 )
end if
end procedure
onKeyPress[EditText2] = routine_id("EditText2_onKeyPress")

----
procedure EditText3_onKeyPress ( int keyCode, int shift )
if keyCode = 13  then
    setFocus( EditText4 )
end if
end procedure
onKeyPress[EditText3] = routine_id("EditText3_onKeyPress")

----
procedure EditText4_onKeyPress ( int keyCode, int shift )
-- whatever you want to happen on last entry
end procedure
onKeyPress[EditText4] = routine_id("EditText4_onKeyPress")



WinMain( Window1, Normal )

----- Original Message -----
From: "joshua goldberg" <futures8 at bellsouth.net>
To: "EUforum" <EUforum at topica.com>
Sent: Monday, September 10, 2001 5:36 AM
Subject: [WIN] determining key press


>
> Hi, all.
>
> I'm having trouble understanding how to determine (via Win32lib)
> whether the Enter key was pressed.  I've read the docs in
> Win32lib.ew re: onKeyDown and found them to be unintelligible (to me).
> Also, have found no examples of using onKeyDown in any of the
> sample programs.
>
> My need occurs in a program with a number of EditText fields. If the
> user inadvertantly presses the enter key instead of tabbing to the next
> fields, the program assumes data entry is finished, and then proceeds
> to try to process without the required data, and crashes. I'd like to be
> able to trap the pressing of the Enter key, and just setFocus to the
> next EditText field if that event occured.
>
> After a long, sleepless night trying to solve this, I must turn, once
> again to my knowledgeable mentors. Any help will be gratefully
> received.
>
> Thanks.
> Josh
>
>
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu