Recent

Author Topic: TMemo force scrolling to bottom  (Read 1152 times)

Чебурашка

  • Hero Member
  • *****
  • Posts: 588
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
TMemo force scrolling to bottom
« on: December 19, 2023, 10:17:40 am »
Hello,
I have a TMemo used to display a log that grows because of a ongoing background process. I would like to make sure last line appended is always visible, I was thinking to programmatically set the position of the vscrollbar to max but I don't find a way to do that, so probably my idea isn't working.

How can I get this working?

FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: TMemo force scrolling to bottom
« Reply #1 on: December 19, 2023, 10:29:30 am »
How can I get this working?
Should work out of the box on Windows. For Linux I use:
Code: Pascal  [Select][+][-]
  1.   Memo1.Append('some string');
  2.   {$ifdef linux} // fix gtk bug not updating memo scroll
  3.   Memo1.selstart := MaxInt;
  4.   {$endif}
  5. end;
  6.  
Not my idea but from a fellow forum user (sorry as I can't remember who it is).
Today is tomorrow's yesterday.

Чебурашка

  • Hero Member
  • *****
  • Posts: 588
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: TMemo force scrolling to bottom
« Reply #2 on: December 19, 2023, 11:06:47 am »
Should work out of the box on Windows. For Linux I use:
Code: Pascal  [Select][+][-]
  1.   Memo1.Append('some string');
  2.   {$ifdef linux} // fix gtk bug not updating memo scroll
  3.   Memo1.selstart := MaxInt;
  4.   {$endif}
  5. end;
  6.  

Are you doing some additional setting, maybe in the object inspector? I tried this but it doesn't do
« Last Edit: December 19, 2023, 11:21:49 am by Чебурашка »
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Чебурашка

  • Hero Member
  • *****
  • Posts: 588
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: TMemo force scrolling to bottom
« Reply #3 on: December 19, 2023, 11:17:07 am »
This worked for me:

Code: Pascal  [Select][+][-]
  1.   MemoLog.SelStart := Length(MemoLog.Text);
  2.  
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: TMemo force scrolling to bottom
« Reply #4 on: December 19, 2023, 11:22:00 am »
Are you doing some additional setting, maybe in the object inspector? I tried this but it doesn't do[/code]
Nope. Nothing at all.

the lfm looks like:
Code: [Select]
  object Memo1: TMemo
    Left = 16
    Height = 183
    Top = 8
    Width = 336
    Lines.Strings = (
      'Memo1'
    )
    TabOrder = 0
  end

This worked for me:

Code: Pascal  [Select][+][-]
  1.   MemoLog.SelStart := Length(MemoLog.Text);
  2.  

That is strange. I used to do it like that as well but since the maxint is automatically corrected by the underlying widget implementation it should work. I am using Lazarus 2.2.6 GTK widgetset on Debian Bookworm, Mate desktop.

Thank you for reporting back as I wasn't aware. Probably something that changed overtime in the widget implementation I assume.
« Last Edit: December 19, 2023, 11:25:41 am by TRon »
Today is tomorrow's yesterday.

Чебурашка

  • Hero Member
  • *****
  • Posts: 588
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: TMemo force scrolling to bottom
« Reply #5 on: December 19, 2023, 11:24:24 am »
Nope. Nothing at all.

That is strange. I used to do it like that as well but since the maxint is automatically corrected by the underlying widget implementation it should work. I am using Lazarus 2.2.6 GTK widgetset on Debian Bookworm, Mate desktop.

Prob is bcz I am using qt5 widgets
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: TMemo force scrolling to bottom
« Reply #6 on: December 19, 2023, 11:28:45 am »
Prob is bcz I am using qt5 widgets
Ah, yes that might be a reason for it.

I am not very experienced with all different widgetsets (I hardly have any knowledge about qt5 and Lazarus).
Today is tomorrow's yesterday.

 

TinyPortal © 2005-2018