Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-07

TLabel inside a TScrollBox (under Win32) MouseWheel issue

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sandro Cumerlato

Reference: "[Lazarus] Scrollbox and mousewheel"
http://lists.lazarus.freepascal.org/pipermail/lazarus/2012-July/074650.html

Hello everybody,
I'm writing to you about an issue discovered while using a TLabel inside a TScrollBox (under Win32).

The problem is that the TLabel hides the MouseWheel action of the TScrollBox if the mouse is over the TLabel.

To solve this problem I've exposed the Label1.OnMouseWheel property to call the following ScrollBox1.OnMouseWheel event:

procedure TFormMain.SrollBox1MouseWheel(Sender: TObject; Shift: TShiftState;
  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
  with SrollBoxRight.VertScrollBar do
    Position := Position - Sign(WheelDelta) * Increment;
  Handled := true;
end;

The attached patch exposes the TLabel.OnMouseWheel event to solve the TLabel/TScrollBox MouseWheel issue.

For the same reason, IMHO, other GUI controls that can be inserted into a TScrollBox should expose OnMouseWheel event.

Thank you for reading!

Sandro Cumerlato
-------------- next part --------------
Index: /freepascal/laz/1.3/lcl/stdctrls.pp
===================================================================
--- /freepascal/laz/1.3/lcl/stdctrls.pp	(revisione 45865)
+++ /freepascal/laz/1.3/lcl/stdctrls.pp	(copia locale)
@@ -1502,6 +1502,7 @@
     property OnMouseUp;
     property OnMouseEnter;
     property OnMouseLeave;
+    property OnMouseWheel;
     property OnChangeBounds;
     property OnContextPopup;
     property OnResize;

Reply by email

Sandro Cumerlato
to Sandro Cumerlato

To whom who may concern...

I've created a sample package with an example to demonstrate how to solve this issue without altering the LCL, but providing a derived component instead:

https://code.google.com/p/mousewheelcontrols/

Comments are welcome.

Sandro Cumerlato

Sandro Cumerlato wrote 33 lines
Reference: "[Lazarus] Scrollbox and mousewheel" http://lists.lazarus.freepascal.org/pipermail/lazarus/2012-July/074650.html Hello everybody, I'm writing to you about an issue discovered while using a TLabel inside a TScrollBox (under Win32). The problem is that the TLabel hides the MouseWheel action of the TScrollBox if the mouse is over the TLabel. To solve this problem I've exposed the Label1.OnMouseWheel property to call the following ScrollBox1.OnMouseWheel event: procedure TFormMain.SrollBox1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); begin with SrollBoxRight.VertScrollBar do Position := Position - Sign(WheelDelta) * Increment; Handled := true; end; The attached patch exposes the TLabel.OnMouseWheel event to solve the TLabel/TScrollBox MouseWheel issue. For the same reason, IMHO, other GUI controls that can be inserted into a TScrollBox should expose OnMouseWheel event. Thank you for reading! Sandro Cumerlato

Reply by email