Board index » delphi » Richedit and key input event

Richedit and key input event

I use a richedit to display some rich text,and I need input keys to do
something else rather than edit text.

In Delphi's richedit component,when a key is pressed,it's code is displayed
in richedit automatically even if you have overridden the 'OnKeyDown' or
'OnKeyPress' event to do something else.

How can I disable the internal action of a key input event which is
implemented by delphi defaultly? There are many kind of these actions such
as arrow keys,edit keys and Ctrl+C,Ctrl+V...

--
GuoGuang
ga...@guoguang.com.cn

 

Re:Richedit and key input event


Quote
> I use a richedit to display some rich text,and I need input keys to do
> something else rather than edit text.
> In Delphi's richedit component,when a key is pressed,it's code is displayed
> in richedit automatically even if you have overridden the 'OnKeyDown' or
> 'OnKeyPress' event to do something else.
> How can I disable the internal action of a key input event which is
> implemented by delphi defaultly? There are many kind of these actions such
> as arrow keys,edit keys and Ctrl+C,Ctrl+V...

To prevent further processing of a key set Key := 0 in an OnKeydown event and
Key := #0 in an OnKeyPress event. Note that there are quite a few keys that
will cause both a keydown and keypress event and these are *independent* of
each other!  So you have to null Key in both event handlers. This can be a
bit complicated by the fact that some key combination (e.g. Ctll-I and the
Tab key, Ctrl-M and Enter) create the same keypress event parameters but
different keydown event parameters. Ctrl-A -> #1 in key press, Ctrl-B -> #2
and so on.
Peter Below (TeamB)  100113.1...@compuserve.com)

Other Threads