Sign in Join

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

Mailing lists / lazarus / 2010-03

Grids and DBgrids

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

JoshyFun

Hello Lazarus-List,

Maybe somebody had noted that all keys that perform some action in a DBGrid by default are never passed to the KeyPress event, like return, delete, keyup, keydown,... The reason is that this actions are handled in the keydown event and to note that they are handled by the DBGrid the "Key" variable is set to zero which finally prevent the right key value to be handled by "KeyPress" as zero is "invalid".

I had fixed it in my local copy using the "CanGridHandleKey" but also in "Grids" (TCustomGrid) some keys are handled to perform default operations and when performed the "Key" is set to zero also. I think they can be safelly removed, the zero setting, but I wish to know if somebody is aware of the reason to set them to zero.

If I do not get feedback in 2 or 3 days I'll post the patch in the bugtracker to propose a solution to this problem.

Best regards, JoshyFun

Reply by email

Alexander Klenin
to JoshyFun
JoshyFun wrote 14 lines
Hello Lazarus-List, Maybe somebody had noted that all keys that perform some action in a DBGrid by default are never passed to the KeyPress event, like return, delete, keyup, keydown,... The reason is that this actions are handled in the keydown event and to note that they are handled by the DBGrid the "Key" variable is set to zero which finally prevent the right key value to be handled by "KeyPress" as zero is "invalid". I had fixed it in my local copy using the "CanGridHandleKey" but also in "Grids" (TCustomGrid) some keys are handled to perform default operations and when performed the "Key" is set to zero also. I think they can be safelly removed, the zero setting, but I wish to know if somebody is aware of the reason to set them to zero.

Although I have no particular need for this change, I support it on the general principle. I would go even further and call KeyPress _before_ built-in handler, so that user code could turn off default handling by setting the key code to zero.

Alexander S. Klenin

Reply by email

JoshyFun
to Alexander Klenin

Hello Lazarus-List,

Sunday, March 7, 2010, 4:12:59 AM, you wrote:

AK> Although I have no particular need for this change, I support it AK> on the general principle. I would go even further and call KeyPress AK> _before_ built-in handler, so that user code could turn off AK> default handling by setting the key code to zero.

I'm not sure that I undertand your answer (my english is quite limited). The "desired" behavior is that if user handles KeyDown, KeyPress or KeyUp no default actions are taken ?

I think that that behavior is only possible in OnKeyDown as the others are too late. Current problem is that the internal grid checks destroys key information so any key handled will not be reported in the KeyPress.

I'll try to modify code to accept overriding by users handle, but without destroying "Key" value. I hope no unexpected side effects happend.

Best regards, JoshyFun

Reply by email

Hans-Peter Diettrich
to JoshyFun
Show quoted text 8 lines
AK> Although I have no particular need for this change, I support it AK> on the general principle. I would go even further and call KeyPress AK> _before_ built-in handler, so that user code could turn off AK> default handling by setting the key code to zero. I'm not sure that I undertand your answer (my english is quite limited). The "desired" behavior is that if user handles KeyDown, KeyPress or KeyUp no default actions are taken ?

That IMO should be standard behaviour. First let the user handle the key events, and proceed with the returned key code.

DoDi

Reply by email

Alexander Klenin
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 14 lines
JoshyFun schrieb: > AK> Although I have no particular need for this change, I support it > AK> on the general principle. I would go even further and call KeyPress > AK> _before_ built-in handler, so that user code could turn off > AK> default handling by setting the key code to zero. > > I'm not sure that I undertand your answer (my english is quite > limited). The "desired" behavior is that if user handles KeyDown, > KeyPress or KeyUp no default actions are taken ? That IMO should be standard behaviour. First let the user handle the key events, and proceed with the returned key code.

Yes, this is what I wanted to say.

Alexander S. Klenin

Reply by email