0

What methods should TEdit descendant override in order to react to the OnKeyPressed event itself, instead of some external function?

For clarification: my TEdit have certain symbols that can be typed in, but not all.
The most simple solution is to define OnKeyPressed in the form code, but I want to have an object that takes care of it itself, not delegating it to the TForm descendant.

thomasb
  • 5,816
  • 10
  • 57
  • 92
RomaValcer
  • 2,786
  • 4
  • 19
  • 29
  • What do you mean "reacting to an event", event handlers are called from component code. – Sertac Akyuz Jun 20 '15 at 23:42
  • @SertacAkyuz Well, normally Form that has the element has a procedure to handle this event. How do I make TEdit descendant handle it by itself instead? – RomaValcer Jun 21 '15 at 00:25
  • 2
    For the windows control, DoKeyPress calls KeyPress which you can override. You can set character to #0 and decide if you want to fire the OnKeyPress event there. – Sertac Akyuz Jun 21 '15 at 00:37
  • @SertacAkyuz and how can I deal with onFocus and onLeave? – RomaValcer Jun 21 '15 at 00:40
  • 2
    _and how can I deal with onFocus and onLeave?_ - `procedure DoEnter; virtual; procedure DoExit; virtual;` – Abelisto Jun 21 '15 at 11:09

0 Answers0