Recent

Author Topic: Scrolling ScrollBox to "invisible" child control  (Read 4758 times)

jamie

  • Hero Member
  • *****
  • Posts: 4466
Re: Scrolling ScrollBox to "invisible" child control
« Reply #15 on: May 03, 2021, 11:02:22 pm »
ok attached is an example of problems with forms or controls with no scrollbars showing..

it also can make a control disappear at the top with no way to get it back.

These scrolling features should only work in the presents of an active scrollbar and only limited to a scrollbar range.
The only true wisdom is knowing you know nothing

zoltanleo

  • Sr. Member
  • ****
  • Posts: 306
Re: Scrolling ScrollBox to "invisible" child control
« Reply #16 on: May 04, 2021, 01:46:47 am »
These scrolling features should only work in the presents of an active scrollbar and only limited to a scrollbar range.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2.   function IsChildControl(aControl: TControl): Boolean;
  3.   var
  4.     FControl: TControl = nil;
  5.   begin
  6.     Result:= False;
  7.     FControl:= aControl;
  8.  
  9.     while FControl.Parent <> nil do
  10.     begin
  11.       if FControl.Parent = Self then
  12.       begin
  13.         Result:= True;
  14.         Break;
  15.       end;
  16.       FControl:= FControl.Parent;
  17.     end;
  18.   end;
  19. begin
  20.   if not IsChildControl(TControl(Sender)) then Exit;//Relevant for Scrollbox
  21.   if not Self.AutoScroll then Exit;
  22.   Self.scrollinview(Button2);
  23. end;
?
« Last Edit: May 04, 2021, 01:56:50 am by zoltanleo »
Win10 LTSC x64/Deb 10 amd64/Darwin Cocoa:
Lazarus x32/x64 2.1(r.64226); FPC 3.3.1 (r.47808), FireBird 3.0.7

Sorry for my bad English, I'm using translator ;)

Michl

  • Full Member
  • ***
  • Posts: 217
Re: Scrolling ScrollBox to "invisible" child control
« Reply #17 on: May 04, 2021, 08:47:00 pm »
These scrolling features should only work in the presents of an active scrollbar
OK this has nothing to do with the latest changes and was even possible before the changes.

So by default, it would be good to have a bugreport about it, so the reasons for a behaviour change can be found also in some years.

I understand, why a scrolling feature is usefull, with only visible ScrollBars. I added a check in revision 65085.
Code: [Select]
type
  TLiveSelection = (lsMoney, lsChilds, lsTime);
  TLive = Array[0..1] of TLiveSelection;

Michl

  • Full Member
  • ***
  • Posts: 217
Re: Scrolling ScrollBox to "invisible" child control
« Reply #18 on: May 04, 2021, 08:51:59 pm »
These scrolling features should only work in the presents of an active scrollbar and only limited to a scrollbar range.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2.   function IsChildControl(aControl: TControl): Boolean;
  3.   var
  4.     FControl: TControl = nil;
  5.   begin
  6.     Result:= False;
  7.     FControl:= aControl;
  8.  
  9.     while FControl.Parent <> nil do
  10.     begin
  11.       if FControl.Parent = Self then
  12.       begin
  13.         Result:= True;
  14.         Break;
  15.       end;
  16.       FControl:= FControl.Parent;
  17.     end;
  18.   end;
  19. begin
  20.   if not IsChildControl(TControl(Sender)) then Exit;//Relevant for Scrollbox
  21.   if not Self.AutoScroll then Exit;
  22.   Self.scrollinview(Button2);
  23. end;
I forgot to add the check, if TScrollingWinControl is parent of control. Thank you for the hint. It is now added in latest revision.
Code: [Select]
type
  TLiveSelection = (lsMoney, lsChilds, lsTime);
  TLive = Array[0..1] of TLiveSelection;

jamie

  • Hero Member
  • *****
  • Posts: 4466
Re: Scrolling ScrollBox to "invisible" child control
« Reply #19 on: May 04, 2021, 10:56:28 pm »
That apparently fixed the issue, it no longer scrolls if there are no scrollbars visible.

On a unrelated bug I just found while testing this.

The IO has issues when selecting AutoScroll = true, shrink the form so the scrollbars come on, then set AutoScroll := false and expand the form, the scrollbars don't go away..

 I would expect the form to refresh with no scrollbars when autoScroll is set to false in the OI.

 I actually have to expand the form, toggle the AUtoScroll to correct it..

I guess I can report this as a separate bug.


The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018