Recent

Author Topic: SpeedButton dblclick  (Read 807 times)

eldonfsr

  • Hero Member
  • *****
  • Posts: 557
SpeedButton dblclick
« on: December 19, 2025, 08:51:58 pm »
HI i trying to implement event double click on speedbutton but i don't get trigger always  first click how i can do doubleclick trigger..
some sad timer but i can implement that please help me..
 

CM630

  • Hero Member
  • *****
  • Posts: 1641
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: SpeedButton dblclick
« Reply #1 on: December 19, 2025, 09:21:03 pm »
Try this:

Code: Pascal  [Select][+][-]
  1.  
  2. unit Unit1;
  3.  
  4. {$mode objfpc}{$H+}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Buttons, LCLIntf ;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     SpeedButton1: TSpeedButton;
  17.     procedure SpeedButton1Click(Sender: TObject);
  18.   private
  19.  
  20.   public
  21.  
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.   FirstClick : QWord = 0;
  27.   Latency : QWord = 1000;
  28.  
  29.  
  30. implementation
  31.  
  32. {$R *.lfm}
  33.  
  34. { TForm1 }
  35.  
  36. procedure TForm1.SpeedButton1Click(Sender: TObject);
  37. begin
  38.   if ((GetTickCount64 - FirstClick) < GetDoubleClickTime) then
  39.   begin
  40.     ShowMessage ('double click');
  41.   end
  42.   else
  43.     FirstClick:= GetTickCount64;
  44. end;
  45.  
  46.  
  47. end.
  48.  
  49.  
« Last Edit: December 19, 2025, 10:03:34 pm by CM630 »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

Aruna

  • Hero Member
  • *****
  • Posts: 790
Re: SpeedButton dblclick
« Reply #2 on: December 20, 2025, 06:36:33 am »
HI i trying to implement event double click on speedbutton but i don't get trigger always  first click how i can do doubleclick trigger..
some sad timer but i can implement that please help me..

Use  OnMouseDown + ssDouble. [ LCL reports double-clicks via the mouse shift state, not via OnClick. ]
Code: Pascal  [Select][+][-]
  1. procedure TForm1.SpeedButton1MouseDown(
  2.   Sender: TObject;
  3.   Button: TMouseButton;
  4.   Shift: TShiftState;
  5.   X, Y: Integer);
  6. begin
  7.   if ssDouble in Shift then
  8.   begin
  9.     ShowMessage('Double click detected');
  10.   end;
  11. end;

This works reliably, no timer needed.
« Last Edit: December 20, 2025, 06:38:53 am by Aruna »

eldonfsr

  • Hero Member
  • *****
  • Posts: 557
Re: SpeedButton dblclick
« Reply #3 on: December 24, 2025, 03:58:17 pm »
Ok Thanks, great help

Thaddy

  • Hero Member
  • *****
  • Posts: 18764
  • To Europe: simply sell USA bonds: dollar collapses
Re: SpeedButton dblclick
« Reply #4 on: December 25, 2025, 02:22:54 pm »
Implementing doubleclick on TSpeedbutton? It is by design it isn't there.... Hence the name: TSpeedButton...
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

CM630

  • Hero Member
  • *****
  • Posts: 1641
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: SpeedButton dblclick
« Reply #5 on: December 26, 2025, 11:09:50 am »
TSpeedButton has a published OnDblClick event and it does not work.
I find that confusing.
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

Thaddy

  • Hero Member
  • *****
  • Posts: 18764
  • To Europe: simply sell USA bonds: dollar collapses
Re: SpeedButton dblclick
« Reply #6 on: December 26, 2025, 12:10:51 pm »
Yes, you can not un-publish that one.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

 

TinyPortal © 2005-2018