Recent

Author Topic: [solved] triple click  (Read 1002 times)

dbannon

  • Hero Member
  • *****
  • Posts: 3213
    • tomboy-ng, a rewrite of the classic Tomboy
[solved] triple click
« on: January 15, 2025, 11:34:21 am »
I'd like to detect a triple click in a control that does not support it. Seems easy enough to detect a double click, and if a third click happens in, say, 500mS, it must be a triple. I'll be overwriting anything the double click did so, seems safe :

Code: Pascal  [Select][+][-]
  1. const CountSinceDouble : qword = 0;
  2.  
  3. procedure TForm.KMemo1MouseDown(Sender : TObject;  Button : TMouseButton; Shift : TShiftState; X, Y : Integer);
  4. begin
  5.     if ssDouble in Shift then
  6.         CountSinceDouble := gettickcount64()
  7.     else if (gettickcount64() - CountSinceDouble) < 500  then
  8.         showmessage('triple click');
  9. end;
   

I don't want to delve too deeply into KMemo, the control in question, it's several layers down from TControl so restoring its ssTriple is too much trouble. Anyone know a better way or see an inherent flaw in what I have done ?

Thanks,

Davo
« Last Edit: January 16, 2025, 01:46:49 am by dbannon »
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10794
  • Debugger - SynEdit - and more
    • wiki
Re: triple click
« Reply #1 on: January 15, 2025, 11:46:51 am »
Not sure, but should multi clicks occur in the approx same location? => If the 3rd click appears some other place... E.g. another line or paragraph...

Or if there was a click to another control inbetween... (ok, needs a very fast user)

dbannon

  • Hero Member
  • *****
  • Posts: 3213
    • tomboy-ng, a rewrite of the classic Tomboy
Re: triple click
« Reply #2 on: January 15, 2025, 12:23:40 pm »
Hmm, I cannot both move and triple click. But I'm using a touchpad.  Might need to do some experiments with a real mouse. 

Good point Martin.

In the event of movement, I would have only the coordinates of the third click available. But I'd think that would probably the correct ones to select anyway, wouldn't you ?

Will report back ...

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Tony Stone

  • Sr. Member
  • ****
  • Posts: 267
Re: triple click
« Reply #3 on: January 15, 2025, 05:50:22 pm »
Does your touchpad have a real right and left button?  My Dell Laptop has them but they are annoying to press.  Usually I do clicks by tapping or double tapping anywhere on the touchpad.  But when I need to do a real triple click I almost always have to use the physical touch pad buttons.  Like in my browser to type in a new URL I use the button to triple click and select all of the text in the address bar.  So just letting you know in other applications on another popular Laptop with a touchpad "triple taps" don't really work as they should.

Hmm, I cannot both move and triple click. But I'm using a touchpad.  Might need to do some experiments with a real mouse. 

Good point Martin.

In the event of movement, I would have only the coordinates of the third click available. But I'd think that would probably the correct ones to select anyway, wouldn't you ?

Will report back ...

Davo


« Last Edit: January 15, 2025, 07:33:42 pm by Tony Stone »

jamie

  • Hero Member
  • *****
  • Posts: 6801
Re: triple click
« Reply #4 on: January 15, 2025, 07:18:58 pm »
That should built from a tcontrol which does have a triple click message u should be able to capture if u subclass the control locally there intercepting the window procedure.
The only true wisdom is knowing you know nothing

Zoran

  • Hero Member
  • *****
  • Posts: 1900
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: triple click
« Reply #5 on: January 15, 2025, 08:25:18 pm »
You can easily access TControl.OnTripleClick using the "protected hack" technique.
Take a look at the attached project (I don't have TKMemo, so in my example I used TStringGrid, which also does not have OnTripleClick event).
« Last Edit: January 15, 2025, 08:31:55 pm by Zoran »
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

dbannon

  • Hero Member
  • *****
  • Posts: 3213
    • tomboy-ng, a rewrite of the classic Tomboy
Re: triple click
« Reply #6 on: January 16, 2025, 01:46:22 am »
Nice one Zoran, very nice !

I just tried it with KMemo and it works flawlessly. Thanks very much.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018