Recent

Author Topic: TScrollBox: scrollbars issue  (Read 1214 times)

apeoperaio

  • Full Member
  • ***
  • Posts: 133
TScrollBox: scrollbars issue
« on: October 10, 2018, 10:06:25 am »
I have an issue with TScrollBox.
Look at the source below. A Tscrollbox aligned alClient with a Tempo a TListbox and a TButton.

Code: Pascal  [Select]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     ListBox1: TListBox;
  17.     Memo1: TMemo;
  18.     ScrollBox1: TScrollBox;
  19.     procedure FormCreate(Sender: TObject);
  20.   private
  21.  
  22.   public
  23.  
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. {$R *.lfm}
  32.  
  33. { TForm1 }
  34.  
  35. procedure TForm1.FormCreate(Sender: TObject);
  36. begin
  37.   memo1.Align:= alTop;
  38.   memo1.Height:= 300;
  39.   ListBox1.Align:= alTop;
  40.   ListBox1.Height:= 300;
  41.   Button1.Align:= alClient;
  42. end;
  43.  
  44. end.
  45.  

When I run my app I can see the vertical scrollbar for few seconds, and I can use I to move on my TScrollBox, but after few seconds the scrollbar disappear and I cannot scroll anymore. In order to make the scrollbar appearing again I must resize the form.



wp

  • Hero Member
  • *****
  • Posts: 5150
Re: TScrollBox: scrollbars issue
« Reply #1 on: October 10, 2018, 10:19:36 am »
If I understand correctly there should not be a scrollbar at all because you client-align the button. Because of the top-aligned memo and listbox and the client-aligned button the scrollbox is completely filled. A scrollbar will appear only when the total extent of the controls within the scrollbox is larger than the clientrect of the scrollbox.

Make the button top-aligned and the scrollbar will be shown if the scrollbox height is less than the combined height of memo, listbox and button.

I don't understand why you see the scrollbar for a few seconds. Please post a complete compilable project.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

apeoperaio

  • Full Member
  • ***
  • Posts: 133
Re: TScrollBox: scrollbars issue
« Reply #2 on: October 10, 2018, 10:32:21 am »
The horizontal scrollbar is not shown, properly, the vertical scrollbar should be shown since I cannot see all my components in the scrollbox. See images.
I attached a sample project. Let me know if I missed something.



wp

  • Hero Member
  • *****
  • Posts: 5150
Re: TScrollBox: scrollbars issue
« Reply #3 on: October 10, 2018, 10:43:23 am »
It's working correctly for me on Windows. But you seem to be on Mac... You should file a bug report then.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

apeoperaio

  • Full Member
  • ***
  • Posts: 133
Re: TScrollBox: scrollbars issue
« Reply #4 on: October 10, 2018, 10:51:15 am »
It's working correctly for me on Windows. But you seem to be on Mac... You should file a bug report then.

It works on windows for me too. I am using Cocoa, so I wrote on Cocoa forum :)

ChrisR

  • Jr. Member
  • **
  • Posts: 75
Re: TScrollBox: scrollbars issue
« Reply #5 on: October 11, 2018, 03:17:09 am »
What version of Lazarus are you using? I tested your project with SVN 59284. With this release, the vertical scroll bar looks fine, and it did not disappear on my MacOS 10.13 laptop. I do not that the horizontal scroll bar does seems a bit funny. It works with your stock application - appearing if you make the app very narrow so you need to scroll to see the TButton. However, if you set the Memo1.WordWrap := false and recompile, launch the program and type a long sting so a horizontal scroll bar would be required to pan to see the text. In this case I do not see the horizontal scrollbar.

apeoperaio

  • Full Member
  • ***
  • Posts: 133
Re: TScrollBox: scrollbars issue
« Reply #6 on: October 11, 2018, 10:39:17 am »
I am using Lazarus 2.1.0 r59284 FPC 3.0.4 x86_64-darwin-cocoa (alpha).
The vertical scrollbar works perfectly on panels, buttons, labels etc. but seems that on control including a scrollbar by themselves (or scrollable components, like memo, listbox etc) the TScrollBox scrollbar does not appear.

MISV

  • Sr. Member
  • ****
  • Posts: 493
Re: TScrollBox: scrollbars issue
« Reply #7 on: October 21, 2018, 05:52:03 pm »
Just for reference: I experience similar issues with TScrollBox