Recent

Author Topic: changing TEdit blocked by menu shortcuts [closed]  (Read 728 times)

kegge13

  • New Member
  • *
  • Posts: 45
    • the BistroMath project
changing TEdit blocked by menu shortcuts [closed]
« on: January 23, 2023, 10:31:25 pm »
Make a form with a TEdit. Compile it. When you enter the TEdit (on the Windows platform with a mouse click) you can type any text.
No add a menu item "Clear" with shortcut "C". Assign a OnClick event the clears the TEdit. (Edit1.Clear;).
Compile it again and enter the TEdit. If you type (for example) "Beware of c" the text will be cleared on the "c".

To avoid this behavior I made an OnEnter event for the TEdit that disables all menu-items.
Imho all input should be handled by the TEdit first. Now it is seen and handled by the menu system while in change mode of the TEdit. Is there another way to avoid this?
« Last Edit: January 24, 2023, 02:31:11 pm by kegge13 »

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: changing TEdit blocked by menu shortcuts
« Reply #1 on: January 23, 2023, 10:49:27 pm »
That's how it should be... The shortcuts should not be any of the keys which the user typically will type. Therefore, they are either the function keys or normal keys combined with ALT/CTRL/SHIFT (of course, SHIFT+c will give you the same result, and CTRL+C is reserved for "copy to clipboard". ALT+C should be fine, though).

kegge13

  • New Member
  • *
  • Posts: 45
    • the BistroMath project
Re: changing TEdit blocked by menu shortcuts
« Reply #2 on: January 23, 2023, 11:15:12 pm »
That's how it should be... The shortcuts should not be any of the keys which the user typically will type. Therefore, they are either the function keys or normal keys combined with ALT/CTRL/SHIFT (of course, SHIFT+c will give you the same result, and CTRL+C is reserved for "copy to clipboard". ALT+C should be fine, though).

Thank you for your response. I made an application where all viewing options used plain keys and shift/alt/ctrl combinations for other menus. It works great, except for a TEdit, that is. But I do not understand why the order should be first menu, then input to an active TEdit. Imho the latter should go first.

Theo

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: changing TEdit blocked by menu shortcuts
« Reply #3 on: January 23, 2023, 11:32:32 pm »
maybe you are referring to the AUTOSELECT property?

If not, can you create a short animation of your screen that shows it?
The only true wisdom is knowing you know nothing

Zvoni

  • Hero Member
  • *****
  • Posts: 2300
Re: changing TEdit blocked by menu shortcuts
« Reply #4 on: January 24, 2023, 10:21:06 am »
But I do not understand why the order should be first menu, then input to an active TEdit. Imho the latter should go first.

Theo
Because a shortcut is global to the Object it is assigned to (in your case the Form), and will always have priority. Period!

And i agree with wp: Bad Design!
The moment you introduce another control (e.g. ComboBox or a Grid) the user can control with the keybord, the moment the user hits c while focus is on that control it would clear your TEdit.

Bottom Line: If you have a Form with keyboard-"editable" controls never ever use "plain" shortcuts. Even shortcuts like SHIFT+C are a timebomb.
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

kegge13

  • New Member
  • *
  • Posts: 45
    • the BistroMath project
Re: changing TEdit blocked by menu shortcuts
« Reply #5 on: January 24, 2023, 02:26:24 pm »
Because a shortcut is global to the Object it is assigned to (in your case the Form), and will always have priority. Period!

And i agree with wp: Bad Design!
The moment you introduce another control (e.g. ComboBox or a Grid) the user can control with the keybord, the moment the user hits c while focus is on that control it would clear your TEdit.

@Zvoni: thank you for the clarification. And yes, in general I agree with the "Bad Design!" remark of @wp. And when I designed it that application that way (not using c to clear a TEdit, that was just an example). I was aware of the implications, and there were more reasons to switch menu branches selectively on and off.
I made a small mp4 movie as demo, see att. but consider this topic as closed.

Thank you all, Hero contributors!
Theo

 

TinyPortal © 2005-2018