Jump to content
PiotrCh

TStringGrid / TDrawGrid with goEditing off generates keystroke issues

Recommended Posts

When TStringGrid or TDrawGrid is read only (goEditing off), than I see issues with the keyboard.

If there is somewhere e.g. label with Caption="&Word Wrap", than

when grid is focused and I press "W", the action Alt+W is triggered without me pressing Alt.

 

This is super easy to replicate, can someone comment what is going on? And how to fix it or mitigate?

 

Reagrds,

Piotr

Share this post


Link to post
7 hours ago, PiotrCh said:

When TStringGrid or TDrawGrid is read only (goEditing off), than I see issues with the keyboard.

If there is somewhere e.g. label with Caption="&Word Wrap", than

when grid is focused and I press "W", the action Alt+W is triggered without me pressing Alt.

 

This is super easy to replicate, can someone comment what is going on? And how to fix it or mitigate?

 

Reagrds,

Piotr

It has worked this way for many Windows versions: if the control with focus is not editable a shortcut will be triggered if the matching character key is pressed even if Alt is not held down. The VCL just adheres to that Microsoft UI design choice.  You can add a handler for the parent form's OnShortcut event (or override the virtual IsShortcut method) to change the default behaviour.

 

If you want to learn more about key handling in a VCL app here is a link to an old article of mine on the subject (Delphi 7 vintage).

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×