How to remove focus rectangle from a button control?
Asked Answered
B

2

6

I need to remove a button focus rectangle, because it looks bad over the TBitBtn glyph after the buttons is clicked.

Beforetime answered 9/3, 2013 at 22:51 Comment(3)
may be setting Focused := false; in the OnClick after all?Mima
Or use a speedbutton instead?Nostomania
Both answers were great,thanks a lot :)Fowle
E
6

You can create an Interposer class for TBitBtn and override SetButtonStyle preventing it's internal IsFocused variable to be set:

type
  TBitBtn = class(Buttons.TBitBtn)
  protected
    procedure SetButtonStyle(ADefault: Boolean); override;
  end;

...
implementation

procedure TBitBtn.SetButtonStyle(ADefault: Boolean);
begin
  inherited SetButtonStyle(False);
end;

This will result a TBitBtn with no focus rectangle. (Tested with D7 - with/without Theme support).

Elwira answered 10/3, 2013 at 20:9 Comment(0)
N
3

As a workaround, you can use a TSpeedButton, which does not take the focus and, consequently, never receives a focus rectangle.

Nostomania answered 10/3, 2013 at 1:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.