Recent

Author Topic: [Solved] TBCTrackBarUpDown OnMouseDown event not working  (Read 1177 times)

petevick

  • Sr. Member
  • ****
  • Posts: 337
[Solved] TBCTrackBarUpDown OnMouseDown event not working
« on: May 24, 2022, 07:15:08 am »
I've been trying to use the OnMouseDown event in a TBCTrackBarUpDown, specifically checking for mbRight using the Button parameter, but it seems unresponsive. The OnMouseDown event in a TPanel works as expected. Is this a known bug ?

I've just tried mbLeft and mbMiddle and both are also unresponsive.
« Last Edit: May 26, 2022, 06:01:38 pm by petevick »
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

petevick

  • Sr. Member
  • ****
  • Posts: 337
Re: TBCTrackBarUpDown OnMouseDown event not working
« Reply #1 on: May 25, 2022, 09:32:01 am »
I think I've answered this. I was comparing BCButtonFocus.pas with BCTrackbarUpdown.pas and noticed the following line that was in the BCButtonFocus.pas MouseDown procedure but not in the BCTrackbarUpdown.pas MouseDown procedure......
Code: Pascal  [Select][+][-]
  1.   inherited MouseDown(Button, Shift, X, Y);
...so I added it to BCTrackbarUpdown.pas, rebuilt Lazarus, and to my utter amazement, OnMouseDown events are now working for the BCTrackbarUpdown control. *pats himself on the back;D
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: TBCTrackBarUpDown OnMouseDown event not working
« Reply #2 on: May 25, 2022, 09:51:13 am »
Please log a bug report or it is unlikely to be fixed as very few developers read the forums.

petevick

  • Sr. Member
  • ****
  • Posts: 337
Re: TBCTrackBarUpDown OnMouseDown event not working
« Reply #3 on: May 25, 2022, 09:58:56 am »
Please log a bug report or it is unlikely to be fixed as very few developers read the forums.
Where do I log the report ??
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: TBCTrackBarUpDown OnMouseDown event not working
« Reply #4 on: May 25, 2022, 10:02:00 am »
Left column on this page, there is a link to the Lazarus > Bugtracker on GitLab.

petevick

  • Sr. Member
  • ****
  • Posts: 337
Re: TBCTrackBarUpDown OnMouseDown event not working
« Reply #5 on: May 25, 2022, 10:04:43 am »
Left column on this page, there is a link to the Lazarus > Bugtracker on GitLab.
Thanks, I'll get on to it  ;)
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

petevick

  • Sr. Member
  • ****
  • Posts: 337
Re: TBCTrackBarUpDown OnMouseDown event not working
« Reply #6 on: May 25, 2022, 11:10:24 am »
OK, not quite the fix I thought it was, Windows 10 gives an 'External SIGEGV' error when you left click on the control. That goes above my pay grade  :(
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: TBCTrackBarUpDown OnMouseDown event not working
« Reply #7 on: May 25, 2022, 11:36:21 am »
Left column on this page, there is a link to the Lazarus > Bugtracker on GitLab.
Thanks, I'll get on to it  ;)

See my note in the bugtracker please.

Bart

petevick

  • Sr. Member
  • ****
  • Posts: 337
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

petevick

  • Sr. Member
  • ****
  • Posts: 337
Re: TBCTrackBarUpDown OnMouseDown event not working
« Reply #9 on: May 26, 2022, 09:57:19 am »
I've had another look at this and for some reason I cannot reproduce the 'External SIGEGV' error in Windows10. However when I left click the control on the right side the trackbar, the indicator jumps to the left. After some experiments, if I place the....
Code: Pascal  [Select][+][-]
  1. inherited MouseDown(Button, Shift, X, Y);
line at the very end of the MouseDown procedure, rather than at the beginning, then all mouse events seem to give the correct behaviour in both Linux and Windows10.

similar message added to bug report
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

petevick

  • Sr. Member
  • ****
  • Posts: 337
Re: TBCTrackBarUpDown OnMouseDown event not working
« Reply #10 on: May 26, 2022, 10:02:37 am »
for clarification, this is the full MouseDown procedure

Code: Pascal  [Select][+][-]
  1. procedure TCustomBCTrackbarUpdown.MouseDown(Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. begin
  4. //  inherited MouseDown(Button, Shift, X, Y);  << original position, gives unexpected behaviour in Windows10
  5.   X := round(X*FCanvasScaling);
  6.   Y := round(Y*FCanvasScaling);
  7.   if Button = mbLeft then
  8.   begin
  9.     FHandlingUserInput:= true;
  10.     if X >= FUpDownLeft then
  11.     begin
  12.       if Y > FDownButtonTop then
  13.       begin
  14.         FDownClick:= true;
  15.         Value := Value-Increment;
  16.         Invalidate;
  17.         FTimer.Interval := LongTimeInterval;
  18.         FTimer.Enabled:= true;
  19.       end else
  20.       if Y < FDownButtonTop then
  21.       begin
  22.         FUpClick:= true;
  23.         Value := Value+Increment;
  24.         Invalidate;
  25.         FTimer.Interval := LongTimeInterval;
  26.         FTimer.Enabled:= true;
  27.       end;
  28.     end else
  29.     if (Y >= Height-FBarHeight-1) and (FBarWidth>1) then
  30.     begin
  31.       FBarClick:= true;
  32.       Value := BarPosToValue(X);
  33.       Repaint;
  34.     end;
  35.     FHandlingUserInput:= false;
  36.   end;
  37.   if not Focused then
  38.   begin
  39.     SetFocus;
  40.     SelectAll;
  41.   end;
  42.   inherited MouseDown(Button, Shift, X, Y);  //<< this position gives expected behaviour in Linux and Windows10
  43. end;
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: TBCTrackBarUpDown OnMouseDown event not working
« Reply #11 on: May 26, 2022, 05:58:22 pm »
Thanks, fixed in dev-bgracontrols branch.

petevick

  • Sr. Member
  • ****
  • Posts: 337
Re: TBCTrackBarUpDown OnMouseDown event not working
« Reply #12 on: May 26, 2022, 06:01:18 pm »
Thanks, fixed in dev-bgracontrols branch.
Thanks lainz  ;)
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

 

TinyPortal © 2005-2018