Make TFPMemo view srollable even if no scrollbars are attached to it

This commit is contained in:
Margers 2025-01-09 21:31:15 +00:00 committed by Michael Van Canneyt
parent 51055fa196
commit 24f498292a
2 changed files with 21 additions and 4 deletions

View File

@ -5012,6 +5012,7 @@ end;
procedure TFPMemo.HandleEvent(var Event: TEvent);
var DontClear: boolean;
S: string;
LineCount,LinesScroll : Sw_Integer;
begin
case Event.What of
evKeyDown :
@ -5028,6 +5029,22 @@ begin
end;
if not DontClear then ClearEvent(Event);
end;
evMouseDown:
if (Event.Buttons=mbScrollUp) then { mouse scroll up}
begin
LinesScroll:=1;
if Event.Double then LinesScroll:=LinesScroll+4;
LineCount:=Max(GetLineCount,1);
ScrollTo(Delta.X,Min(Max(0,LineCount-Size.Y),Delta.Y+LinesScroll));
ClearEvent(Event);
end else
if (Event.Buttons=mbScrollDown) then { mouse scroll down }
begin
LinesScroll:=-1;
if Event.Double then LinesScroll:=LinesScroll-4;
ScrollTo(Delta.X, Max(0,Delta.Y+LinesScroll));
ClearEvent(Event);
end;
end;
inherited HandleEvent(Event);
end;

View File

@ -3583,10 +3583,10 @@ end;
procedure TCustomCodeEditor.ScrollTo(X, Y: sw_Integer);
begin
inherited ScrollTo(X,Y);
if (HScrollBar=nil) or (VScrollBar=nil) then
begin Delta.X:=X; Delta.Y:=Y; end;
DrawView;
inherited ScrollTo(X,Y);
if (HScrollBar=nil) then Delta.X:=Max(X,0);
if (VScrollBar=nil) then Delta.Y:=Max(Min(Y,GetLineCount-1),0);
if (HScrollBar=nil) or (VScrollBar=nil) then DrawView;
end;
function TCustomCodeEditor.IsModal: boolean;