Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Button with VCL Styles

Tags:

delphi

I am puzzled by the styling of TButtons that have Default:=True. The issue is that at least with some styles (Luna, for example), the most recently focused button is highlighted orange, which is the same styling used for a default button. As a result, I am concerned that users might be confused as to which button is the default or will at least think it odd that two buttons are highlighted. This behavior can be seen in XE7 (and according to a comment, also in XE8). Questions:

  1. Is this considered a modern way (relatively to unstyled VCL) to present default buttons?
  2. If this is not considered standard behavior I can work around it in my own dialogs by strategically enabling/disabling the default button, but I was wondering whether I missed some setting that controls the relation between default buttons and the most-recently focused button. Is there a setting that controls this?
like image 270
TomT Avatar asked Aug 23 '26 20:08

TomT


1 Answers

I suspect that this is a VCL styles bug. Create a default VCL application that uses the standard OS theme. Then add two buttons and an edit control. Make one of the buttons be the default button.

Now use the tab key to cycle round the focus. When the edit control has the focus, the default button is highlighted. That indicates that if you press ENTER then that button will be pressed.

However, if either of the buttons has the focus, then the button with the focus is highlighted. That's because if you press ENTER when a button has the focus, the focused button is pressed, irrespective of whether it is the default button.

The rules are as follows:

  • If a button has the focus, it is highlighted as the default button.
  • If a control other than a button has the focus, the default button, if there is one, is highlighted.

So, here's what the application looks like in XE7 with the system theme. The non-default button has the focus.

enter image description here

Note that only one button is highlighted, and it is not the default button.

And here is the same application in XE7 with the Luna style.

enter image description here

Here we have the default button, and the button with the focus, both being highlighted. I would regard that to be a bug, and it should be reported.

like image 199
David Heffernan Avatar answered Aug 26 '26 15:08

David Heffernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!