views:

50

answers:

1

I was using two TButton components on a form that functioned as Plus and Minus. When clicked they would add or subtract from an integer which would then be displayed on a TLabel.

This functioned as desired where the speed at which I would click would fire the OnClick event without fault.

I have replaced the buttons with PNGButton components so that I could make them look more pretty. Everything still works as before except that the OnClick event doesn't seem to be firing every time I click the components. I tested this with a simple TImage component also and the result is the same.

If I click very slowly it will fire every time, but if I click at a regular pace it only seems to fire every second click.

What can I do to make sure that the OnClick event is fired every time?

+1  A: 

Instead of using the OnClick event, use the OnMouseUp event:

procedure TForm.btnMinusMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Self.NumSelected > 0 then begin
    Self.NumSelected := Self.NumSelected - 1;
    Self.UpdateLabel;
  end;
end;
Simon Hartcher
Perhaps some explanation might help. I suspect that the OnClick is not registering because it is being considered a double-click. The mouse up is not dependent on the click interpretation, so works.
mj2008