开发者

OnClick event firing speed for components

开发者 https://www.devze.com 2022-12-10 19:33 出处:网络
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.

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 t开发者_运维百科hat the OnClick event is fired every time?


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消