Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-01

Handle user inputs

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

xrfang

Hi,

I want to use TApplicationProperties.OnUserInput to process keyboard/mouse events. ?But the parameter of this method is a Cardinal. ? My questions are:

1) How do I know its event type, such as keydown/keyup/keypress or mouse move etc?

2) How do I know the actual key that is pressed, or the X, Y coordinates of the mouse?

Thanks,
Shannon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130121/6a5de48e/attachment-0001.html>

Reply by email

Mattias Gaertner
to xrfang
Show quoted text 6 lines
Hi, I want to use TApplicationProperties.OnUserInput to process keyboard/mouse events. ?But the parameter of this method is a Cardinal. My questions are: 1) How do I know its event type, such as keydown/keyup/keypress or mouse move etc?

if Msg=LM_KEYDOWN then ...

2) How do I know the actual key that is pressed, or the X, Y coordinates of the mouse?

To interpret key and coordinates correctly you need the context. If you want context-specific events then you have to use the events of the context, e.g. the form, button, etc.

Mattias

Reply by email

xrfang
to xrfang: I want to use TApplicationProperties.OnUserInput to process keyboard/mouse events. ?But…

Hi Mattias,

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

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.

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?

Attached is a draft of my tpaintrect class.

Thanks a lot.

Sincerely,
Shannon

? ?, 1? 21, 2013 at 3:08 ???xrfang ???
Hi,

I want to use TApplicationProperties.OnUserInput to process keyboard/mouse events. ?But the parameter of this method is a Cardinal. ? My questions are:

1) How do I know its event type, such as keydown/keyup/keypress or mouse move etc?

2) How do I know the actual key that is pressed, or the X, Y coordinates of the mouse?

Thanks,
Shannon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130121/5a5b4c03/attachment-0001.html> -------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tar.bz2
Type: application/x-bzip-compressed-tar
Size: 71680 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130121/5a5b4c03/attachment-0001.bin>

Reply by email

Mattias Gaertner
to xrfang
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

Reply by email