FMX: Vertical Scrollbox scroll programmatically not working

  

Hello Stack Community,

Right now I’m developing an application for Android and iOS.
I have a FMX Form with a TabControl. At Runtime I create Tabitems with a TVerticalScrollBox with several custom Panelclasses as Children. I created swipe gestures (left & right) to change between the TabItems, which is working perfectly. But when I want to scroll up and down my Custom Panels are catching the swipe gesture and not the Scrollbox. So I’m catching the swipe gestures (up & down) with my custom panels and try to scroll the VerticalScrollBox by Code, which is not working. I’m able to get the Owner (VerticalScrollbox) of the CustomPanel and parse it to a TVerticalScrollBox Component. But when I’m calling the ScrollBy Procedure of the VerticalScrollbox nothing happens. Any Suggestions or Workarounds?

Best Regards

some sample code

The ScrollBox I create at Runtime:

lScrollBox := TVertScrollBox.Create(lItem);
lScrollBox.Parent := LItem;
lScrollBox.Name := lScrollBox.ClassName + ‘_’ +
inttoStr(i);
lScrollBox.Align := TAlignLayout.Client;
lScrollBox.ShowScrollBars := False;
lScrollBox.Visible := True;
lScrollBox.Touch.GestureManager := lGesture;
lScrollBox.Touch.StandardGestures := [TStandardGesture.sgLeft, TStandardGesture.sgRight,TStandardGesture.sgUp,TStandardGesture.sgDown];
lScrollBox.Touch.InteractiveGestures := [TInteractiveGesture.Pan];
lScrollBox.OnGesture := onGesture;

my Custom Panels I Create at Runtime…

Test := TjilsDatePanel.Create(lScrollBox);
Test.Parent := lScrollBox;
Test.TabNumber := i;
Test.ObjectNumber := strtoint(jDate.GetValue<string>(‘key’));
Test.Name := ‘Test’+ jDate.GetValue<string>(‘key’);
Test.Therapy := jDate.GetValue<string>(‘Therapie’);
Test.Start := jDate.GetValue<string>(‘Start’);
Test.Ende := jDate.GetValue<string>(‘Ende’);
Test.Info := jDate.GetValue<string>(‘Termin’);
Test.Touch.GestureManager := lGesture;
Test.Touch.StandardGestures := [TStandardGesture.sgLeft, TStandardGesture.sgRight, TStandardGesture.sgUp, TStandardGesture.sgDown];
Test.Touch.InteractiveGestures := [TInteractiveGesture.pan,TInteractiveGesture.LongTap];
Test.OnGesture := onGesture;
Test.setlGesture(lGesture);
Test.setTabControl(lTabControl);

Test.createObjects(Test.TabNumber);

also my onGesture Procedure…

procedure TReTinAMainLogicLayer.onGesture(Sender: TObject; const EventInfo: TGestureEventInfo; var Handled: Boolean);
begin
if Sender.ClassName = ‘TVertScrollBox’ then
begin
if EventInfo.GestureID = sgiLeft then ChangeTabActionPrevUpdate;
if EventInfo.GestureID = sgiRight then ChangeTabActionNextUpdate;
if EventInfo.GestureID = sgiUp then showMessage(‘TVertScrollBox UP’);
if EventInfo.GestureID = sgiDown then showMessage(‘TVertScrollBox DOWN’);

Handled := true;
end;
if Sender.ClassName = ‘TjilsDatePanel’ then
begin
if EventInfo.GestureID = sgiLeft then ChangeTabActionPrevUpdate;
if EventInfo.GestureID = sgiRight then ChangeTabActionNextUpdate;
if EventInfo.GestureID = igiLongTap then setUpComView(Sender as TjilsDatePanel);
if EventInfo.GestureID = sgiUp then showMessage(‘TjilsDatePanel UP’);
if EventInfo.GestureID = sgiDown then scrollUp(Sender as TjilsDatePanel);
Handled := true;
end;
end;

and finally my scrollUp Procedure…

procedure TReTinAMainLogicLayer.scrollUp(Sender: TjilsDatePanel);
var
VertBox : TVertScrollBox;
begin
if Sender.Owner.ClassNameIs(‘TVertScrollBox’) then
begin
VertBox := Sender.Owner as TVertScrollBox;
VertBox.BeginUpdate;
VertBox.ViewportPosition := TPointF.Zero;
VertBox.ScrollBy(400,400);
VertBox.ScrollTo(500,500);
VertBox.RealignContent;
VertBox.EndUpdate;
end;
end;

Comments are closed.