Search code examples
androidiosdelphitouchfiremonkey

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?


Solution

  • 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