Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TLabel OnMouseDown event not firing in Firemonkey

I'm trying to change a TLabel color when the user touches it, but it looks like the MouseDown event is not being fired.

procedure TForm_Master.tv_1Down(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
tv_1.FontColor := TAlphaColors.Dodgerblue;
end;

What could possibly be going wrong?

like image 466
Machado Avatar asked Feb 09 '23 19:02

Machado


1 Answers

If we set HitTest to True, this control captures all mouse OnClick and OnDblClick events.

If we set HitTest to False, these two mouse-click events will pass through this control, so that a control laid out behind this one receives the mouse events instead of this control.

For most controls, HitTest is True by default. However, this is not true for TLabel and TPathLabel, where HitTest is False by default; these two controls do not capture the OnClick and OnDblClick events unless you set HitTest to True.

http://docwiki.embarcadero.com/Libraries/XE8/en/FMX.Controls.TControl.HitTest

like image 144
Machado Avatar answered Feb 11 '23 16:02

Machado