Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   Wieder einmal Autoscroll im Memo-Feld (https://www.delphipraxis.net/216560-wieder-einmal-autoscroll-im-memo-feld.html)

Rued 17. Jan 2025 17:32

Wieder einmal Autoscroll im Memo-Feld
 
Hallo!

Ich nutze für meine Android-App ein Memo-Feld im Read-only-Modus, das in der gewählten Schriftgröße Platz für 24 Zeilen hat. Ist es möglich, das Memo zu einem Autoscroll zu bewegen, wenn eine 25. Zeile hinzugefügt wird, so dass diese als letzte im Memo-Feld angezeigt wird?

Probiert habe ich diese Lösung, die mein Memo kalt lässt. Es rührt sich nichts.

Gruß
Rüd

Rollo62 21. Jan 2025 08:53

AW: Wieder einmal Autoscroll im Memo-Feld
 
Hast Du mal die ScrollTo Optionen angesehen und damit etwas versucht?
Ich nutze ScrollToTop, was bei meiner Anwendung funktioniert, aber solche Basics wie Scrolling sind immer wieder extrem fragil.

Delphi-Quellcode:
procedure TCustomPresentedScrollBox.ScrollToCenter(const AAnimated: Boolean);
var
  ContentBoundsTmp: TRectF;
  ViewportSizeTmp: TSizeF;
  DestPoint: TPointF;
begin
  ContentBoundsTmp := ContentBounds;
  ViewportSizeTmp := ViewportSize;
  DestPoint := TPointF.Create((ContentBoundsTmp.Width - ViewportSizeTmp.Width) / 2, (ContentBoundsTmp.Height - ViewportSizeTmp.Height) /2);
  ScrollBy(DestPoint.X - ViewportPosition.X, DestPoint.Y - ViewportPosition.Y, AAnimated);
end;

procedure TCustomPresentedScrollBox.ScrollToTop(const AAnimated: Boolean = True);
begin
  ScrollBy(0, -ViewportPosition.Y, AAnimated);
end;

Rued 25. Jan 2025 15:21

AW: Wieder einmal Autoscroll im Memo-Feld
 
Zitat:

Zitat von Rollo62 (Beitrag 1545460)
Hast Du mal die ScrollTo Optionen angesehen und damit etwas versucht?
Ich nutze ScrollToTop, was bei meiner Anwendung funktioniert, aber solche Basics wie Scrolling sind immer wieder extrem fragil.

Delphi-Quellcode:
procedure TCustomPresentedScrollBox.ScrollToCenter(const AAnimated: Boolean);
var
  ContentBoundsTmp: TRectF;
  ViewportSizeTmp: TSizeF;
  DestPoint: TPointF;
begin
  ContentBoundsTmp := ContentBounds;
  ViewportSizeTmp := ViewportSize;
  DestPoint := TPointF.Create((ContentBoundsTmp.Width - ViewportSizeTmp.Width) / 2, (ContentBoundsTmp.Height - ViewportSizeTmp.Height) /2);
  ScrollBy(DestPoint.X - ViewportPosition.X, DestPoint.Y - ViewportPosition.Y, AAnimated);
end;

procedure TCustomPresentedScrollBox.ScrollToTop(const AAnimated: Boolean = True);
begin
  ScrollBy(0, -ViewportPosition.Y, AAnimated);
end;

Mit ScrollToTop komme ich super klar. Herzlichen Dank!


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:41 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz