[Lazarus] Handle user inputs

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Jan 21 10:33:00 CET 2013


On Mon, 21 Jan 2013 08:52:32 +0008
xrfang <xrfang at gmail.com> wrote:

> Hi Mattias,
> 
> I try to process keyboard events to a TPaintBox, which does not have OnKeyDown etc.  

A TPainBox can not get focus, so it can not get keyboard events.

 
> I am writing a class which I hope to be as clean as possible. The class is called TPaintRect, which let me paint on certain part (rect) of a canvas.

You could create a component with ancestor TCustomControl. That has a
Canvas and whatever events you need.
 
> I can of course try to interpret keyboard event of the form, but I hope not to interfere with other components (for example, avoid set Form.KeyPreview=true).
> 
> Is it possible?

Yes.

> Attached is a draft of my tpaintrect class.

Mattias




More information about the Lazarus mailing list