Re: Trapping and suppressing Enter key in a rich edit
- Posted by Mario Steele <eumario at tuscanchat.com> Apr 10, 2004
- 537 views
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