Browse Source

FV TScroller and TEditor respond to mouse scroll

Margers 10 months ago
parent
commit
818e3ae6e5
3 changed files with 33 additions and 14 deletions
  1. 15 0
      packages/fv/src/editors.pas
  2. 18 0
      packages/fv/src/views.inc
  3. 0 14
      packages/ide/weditor.pas

+ 15 - 0
packages/fv/src/editors.pas

@@ -2024,6 +2024,7 @@ VAR
   SelectMode   : Byte;
   D            : {$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}Objects.TPoint;
   Mouse        : {$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}Objects.TPoint;
+  LinesScroll  : Sw_Integer;
 
   function CheckScrollBar (P : PScrollBar; var D : Sw_Integer) : Boolean;
   begin
@@ -2047,6 +2048,19 @@ begin
   case Event.What of
     {$IFDEF FPC_DOTTEDUNITS}FreeVision.{$ENDIF}Drivers.evMouseDown:
       begin
+        if (Event.Buttons=mbScrollUp) then { mouse scroll up}
+          begin
+            LinesScroll:=1;
+            if Event.Double then LinesScroll:=LinesScroll+4;
+            ScrollTo(Delta.X, Delta.Y + LinesScroll);
+          end else
+        if (Event.Buttons=mbScrollDown) then  { mouse scroll down }
+          begin
+            LinesScroll:=-1;
+            if Event.Double then LinesScroll:=LinesScroll-4;
+            ScrollTo(Delta.X, Delta.Y + LinesScroll);
+          end else
+        begin
         if Event.Double then
           SelectMode := SelectMode or smDouble;
         repeat
@@ -2069,6 +2083,7 @@ begin
           SelectMode := SelectMode or smExtend;
           Unlock;
         until not MouseEvent (Event, evMouseMove + evMouseAuto);
+        end;
       end; { {$IFDEF FPC_DOTTEDUNITS}FreeVision.{$ENDIF}Drivers.evMouseDown }
 
     {$IFDEF FPC_DOTTEDUNITS}FreeVision.{$ENDIF}Drivers.evKeyDown:

+ 18 - 0
packages/fv/src/views.inc

@@ -3511,8 +3511,26 @@ END;
 {  HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Jul99 LdB       }
 {---------------------------------------------------------------------------}
 PROCEDURE TScroller.HandleEvent (Var Event: TEvent);
+var LinesScroll  : Sw_Integer;
 BEGIN
    Inherited HandleEvent(Event);                      { Call ancestor }
+   case Event.What of
+    evMouseDown:
+      begin
+        if (Event.Buttons=mbScrollUp) then { mouse scroll up}
+          begin
+            LinesScroll:=1;
+            if Event.Double then LinesScroll:=LinesScroll+4;
+            ScrollTo(Delta.X, Delta.Y + LinesScroll);
+          end else
+        if (Event.Buttons=mbScrollDown) then  { mouse scroll down }
+          begin
+            LinesScroll:=-1;
+            if Event.Double then LinesScroll:=LinesScroll-4;
+            ScrollTo(Delta.X, Delta.Y + LinesScroll);
+          end;
+      end;
+   end;
    If (Event.What = evBroadcast) AND
      (Event.Command = cmScrollBarChanged) AND         { Scroll bar change }
      ((Event.InfoPtr = HScrollBar) OR                 { Our scrollbar? }

+ 0 - 14
packages/ide/weditor.pas

@@ -3441,7 +3441,6 @@ var
   E: TEvent;
   OldEvent : PEvent;
   CCAction: TCCAction;
-  LinesScroll : sw_integer;
 begin
   CCAction:=ccClear;
   E:=Event;
@@ -3456,19 +3455,6 @@ begin
     ConvertEvent(Event);
   case Event.What of
     evMouseDown :
-      if MouseInView(Event.Where) then
-       if (Event.Buttons=mbScrollWheelUp) then { mouse scroll up}
-         begin
-           LinesScroll:=1;
-           if Event.Double then LinesScroll:=LinesScroll+4;
-           ScrollTo(Delta.X, Delta.Y + LinesScroll);
-         end else
-       if (Event.Buttons=mbScrollWheelDown) then  { mouse scroll down }
-         begin
-           LinesScroll:=-1;
-           if Event.Double then LinesScroll:=LinesScroll-4;
-           ScrollTo(Delta.X, Delta.Y + LinesScroll);
-         end else
        if (Event.Buttons=mbRightButton) then
          begin
            MakeLocal(Event.Where,P); Inc(P.X); Inc(P.Y);