PiotrCh 0 Posted 14 hours ago 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
PeterBelow 251 Posted 6 hours ago 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
PiotrCh 0 Posted 1 hour ago (edited) Such a pity. It is even more complicated - It depends on a type of control - it doesn't trigger Alt+Key for the main menu, but it triggers for other controls. I know MS has made bad decisions in the past, but they also changed them very often. Their legacy is causing us headaches. Great that Delphi has TForm.OnShortCut() which works perfect for me now. Thanks for pointing this out to me and for the Key's Odyssey. Edited 19 minutes ago by PiotrCh Share this post Link to post