Recent

Author Topic: TUpDown MouseDown  (Read 512 times)

morknot

  • New Member
  • *
  • Posts: 35
  • still learning
TUpDown MouseDown
« on: November 17, 2020, 01:49:29 pm »
I would like to use the MouseDown event of TUpDown to reset its position to zero with the right mouse button. The problem is that the MouseDown event only seems to fire when the mouse cursor is in the narrow gap between the  2 buttons. This makes it very awkward to use as the positioning is pretty precise.

Is there a way around this or should I find an alternative? Thanks.

Laz 2.0.8
Windows10

GetMem

  • Hero Member
  • *****
  • Posts: 3783
Re: TUpDown MouseDown
« Reply #1 on: November 17, 2020, 02:18:29 pm »
I can confirm the behaviour with Lazarus Trunk/FPC 3.2.0/Win10. It's clearly a bug and you should report it on the bugtracker:
 https://bugs.freepascal.org/my_view_page.php
Other then this, resetting the value with right click it seems strange to me. I wouldn't expect such a behaviour from a spinedit like control. Of course this is just my opinion.

howardpc

  • Hero Member
  • *****
  • Posts: 3585
Re: TUpDown MouseDown
« Reply #2 on: November 17, 2020, 02:32:05 pm »
This behaviour arises from the design of the component which is a composite of two specialised buttons placed on a containing control.
As currently designed, the OnMouseDown events of those two buttons are handled internally to the control, and not accessible to the programmer.
However, I see no reason in principle why the design could not be altered to expose more of the internals.

Sieben

  • Full Member
  • ***
  • Posts: 144
Re: TUpDown MouseDown
« Reply #3 on: November 17, 2020, 02:45:51 pm »
You might have to go down to WS level for that. From TCustomUpDown.Create:

Code: Pascal  [Select][+][-]
  1.   FUseWS := IsWSComponentInheritsFrom(TCustomUpDown, TWSCustomUpDown);
  2.   ...
  3.   if not FUseWS then begin
  4.     FMinBtn := TUpDownButton.CreateWithParams(Self, btPrev);
  5.     FMaxBtn := TUpDownButton.CreateWithParams(Self, btNext);
  6.   end;
  7.  
Lazarus 2.0.10, FPC 3.2.0, .deb install on Ubuntu Xenial 32

Bart

  • Hero Member
  • *****
  • Posts: 4042
    • Bart en Mariska's Webstek
Re: TUpDown MouseDown
« Reply #4 on: November 17, 2020, 03:39:57 pm »
Does Delphi have an OnMouseDown for TUpDown?

Bart

morknot

  • New Member
  • *
  • Posts: 35
  • still learning
Re: TUpDown MouseDown
« Reply #5 on: November 17, 2020, 04:08:48 pm »
Delphi 7 does, Bart. Both buttons respond to MouseDown although there is no visual indication with using the right mouse button

wp

  • Hero Member
  • *****
  • Posts: 7750
Re: TUpDown MouseDown
« Reply #6 on: November 17, 2020, 04:29:42 pm »
Resetting the up/down counter by a right-click is very unconventional and no user will find this... The correct way is to add a context menu with a Reset option.

Therefore I played with this idea applied to the TSpinEdit and found another issue: The TSpinEdit does not propagate the PopupMenu to the spin buttons. Only a right-dlick on the edit field opens the popup menu, but not on the spin buttons. This is different from Delphi where the context menu is opened also by a right-click on the spin buttons.

I submitted a report to bug tracker: https://bugs.freepascal.org/view.php?id=38098

« Last Edit: November 17, 2020, 04:53:54 pm by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

morknot

  • New Member
  • *
  • Posts: 35
  • still learning
Re: TUpDown MouseDown
« Reply #7 on: November 17, 2020, 04:36:34 pm »
I understand what is being said about a right click reset being unconventional. But in broader terms, TUpDown is provided with a MouseDown event which is pretty much unusable.

morknot

  • New Member
  • *
  • Posts: 35
  • still learning
Re: TUpDown MouseDown
« Reply #8 on: November 17, 2020, 06:00:13 pm »
Following on from wp's similar issue, I have submitted a bug report as well on TUpDown......

https://bugs.freepascal.org/view.php?id=38099

Bart

  • Hero Member
  • *****
  • Posts: 4042
    • Bart en Mariska's Webstek
Re: TUpDown MouseDown
« Reply #9 on: November 17, 2020, 09:10:51 pm »
See my remarks there.

Bart

Sieben

  • Full Member
  • ***
  • Posts: 144
Re: TUpDown MouseDown
« Reply #10 on: November 18, 2020, 07:17:09 pm »
Seems to work with 64147 now...  :)
Lazarus 2.0.10, FPC 3.2.0, .deb install on Ubuntu Xenial 32

 

TinyPortal © 2005-2018