OnClick occurs on a touchscreen scroll

General TRichView support forum. Please post your questions here
Post Reply
whisper1980
Posts: 26
Joined: Sun May 25, 2025 6:41 pm

OnClick occurs on a touchscreen scroll

Post by whisper1980 »

Me again... Using the eval version under Delphi 12.3

On a touch screen, if I use my finger to slide the content (not using the scrollbar), and I lift my finger, the OnClick even occurs. Bad for me especially if the caret is within a hyperlink... is there a way around that? Tested on Windows and Android.

Edit: Also occurs using the mouse to drag the content up/down rather than the scroll bar (OnClick event occurs when releasing the mouse button)

Eric
Sergey Tkachenko
Site Admin
Posts: 17854
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: OnClick occurs on a touchscreen scroll

Post by Sergey Tkachenko »

OnClick means clicking on control, and TRichView has the default behavior inherited from TControl.
I suggest using other mouse events instead.
whisper1980
Posts: 26
Joined: Sun May 25, 2025 6:41 pm

Re: OnClick occurs on a touchscreen scroll

Post by whisper1980 »

I guess one has to have the mouse up occur off the control to prevent the onclick event. Seems just so stupid to me... it is not a click in my mind. To me a click is a short operation within milliseconds in order to distinguish a short vs long press, drag select text or even a scroll operation. WPTools uses the time between down/up to determine whether to invoke the OnClick event or not which threw me off, thinking it was an issue with TRichView.

I realize now that it is not your issue after all. Sorry.
whisper1980
Posts: 26
Joined: Sun May 25, 2025 6:41 pm

Re: OnClick occurs on a touchscreen scroll

Post by whisper1980 »

Correction... WPTools uses the mouse position between down/up to determine if it it was a click or not.
whisper1980
Posts: 26
Joined: Sun May 25, 2025 6:41 pm

Re: OnClick occurs on a touchscreen scroll

Post by whisper1980 »

FWIW, this is what I did to get around my issue and only do the OnClick event when the mouse/finger up hasn't moved far from the down:

Code: Select all

procedure TForm1.RichViewEdit1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
  fMouseDownPos := TPointF.Create(X, Y);
end;

procedure TForm1.RichViewEdit1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
  fMouseUpPos := TPointF.Create(X, Y);
  if (Abs(fMouseDownPos.X - fMouseUpPos.X) <= 3) and (Abs(fMouseDownPos.Y - fMouseUpPos.Y) <= 3) then
    RichViewEdit1Click(nil);
end;

procedure TForm1.RichViewEdit1Click(Sender: TObject);
begin
  if Sender <> nil then exit;
end;

Post Reply