1. Trapping and suppressing Enter key in a rich edit
- Posted by jtemple at yhti.net
Apr 09, 2004
All,
I want to prevent the Enter key from inserting a CR/LF in a rich edit control.
I've tried the following:
--------------------------------------------------------------------------------
procedure StatementRE_onKeyPress (integer self, integer event, sequence
params)--params is ( int keyCode, int shift )
-- When the user presses enter just execute the sql statement
if params[1] = VK_ENTER and enter_exec_sql then
execute()
returnValue(True)
end if
end procedure
setHandler( StatementRE, w32HKeyDown, routine_id("StatementRE_onKeyPress"))
but I still get a CR/LF in the rich edit. I can't quite figure this one out.
Maybe it's impossible in a rich edit?
TIA,
Jonas
2. Re: Trapping and suppressing Enter key in a rich edit
The documentation of WM_KEYDOWN says:
"An application should return zero if it processes this message."
Perhaps you should try 'returnValue(0)' instead of 'returnValue(True)'.
3. Re: Trapping and suppressing Enter key in a rich edit
- Posted by jtemple at yhti.net
Apr 09, 2004
>The documentation of WM_KEYDOWN says:
>"An application should return zero if it processes this message."
>
>Perhaps you should try 'returnValue(0)' instead of 'returnValue(True)'.
Well, I'm using Win32Lib and the docs saw to use (True) when you don't want
Windows to process the message. I did try using (0) but it produced the same
results.
Jonas
4. Re: Trapping and suppressing Enter key in a rich edit
Guest wrote:
>
>
>posted by: jtemple at yhti.net
>
>All,
>
>I want to prevent the Enter key from inserting a CR/LF in a rich edit control.
>I've tried the following:
>
>>--------------------------------------------------------------------------------
>procedure StatementRE_onKeyPress (integer self, integer event, sequence
>params)--params is ( int keyCode, int shift )
> -- When the user presses enter just execute the sql statement
> if params[1] = VK_ENTER and enter_exec_sql then
> execute()
> returnValue(True)
> end if
>end procedure
>setHandler( StatementRE, w32HKeyDown, routine_id("StatementRE_onKeyPress"))
>
>but I still get a CR/LF in the rich edit. I can't quite figure this one out.
>Maybe it's impossible in a rich edit?
>
>TIA,
>
>Jonas
>
Hey Jonas,
Reason why you'r not stopping the VK_ENTER/VK_RETURN, is the fact that
by default, RichEdit Controls have their own Proccessor for Key Events.
Win32lib never receives these events, unless you specify to the control
that you want to receive these events. I had this same problem myself,
and found this solution to my problem:
void = sendMessage(InputBox,WM_USER+69,0,#04020003) -- EM_SETEVENTMASK,
ENM_UPDATE+ENM_CHANGE+ENM_LINK
void = sendMessage(InputBox,WM_USER+91,1,0)
These two combines will allow Win32lib to receive the Key Events for
ya. It will also notify you of Links, and stuff, and I'm not certian of
the masks for this, but I am sure you can find this information in a
Win32 Raw API Library in the Archives. Once you do the two above
sendMessage() functions, you'll be able to receive the events by the
normal KeyPress, KeyDown, and KeyUp defs in Win32lib.
Hope this helps ya out,
EuMario
5. Re: Trapping and suppressing Enter key in a rich edit
- Posted by jtemple at yhti.net
Apr 13, 2004
Mario,
Thanks for the code example. I probably should have clarified one point,
though. I was able to trap the Enter key in a rich edit with the w32HKeyDown
event handler but what I'm trying to do is stop the rich edit from inserting a
CR/LF.
Thanks for the help!
Jonas
Hey Jonas,
Reason why you'r not stopping the VK_ENTER/VK_RETURN, is the fact that
by default, RichEdit Controls have their own Proccessor for Key Events.
Win32lib never receives these events, unless you specify to the control
that you want to receive these events. I had this same problem myself,
and found this solution to my problem:
void = sendMessage(InputBox,WM_USER+69,0,#04020003) -- EM_SETEVENTMASK,
ENM_UPDATE+ENM_CHANGE+ENM_LINK
void = sendMessage(InputBox,WM_USER+91,1,0)
These two combines will allow Win32lib to receive the Key Events for
ya. It will also notify you of Links, and stuff, and I'm not certian of
the masks for this, but I am sure you can find this information in a
Win32 Raw API Library in the Archives. Once you do the two above
sendMessage() functions, you'll be able to receive the events by the
normal KeyPress, KeyDown, and KeyUp defs in Win32lib.
Hope this helps ya out,
EuMario