Robson Benedito
Robson Benedito

Reputation: 145

How to disable listbox scroll inside a TVertScrollBar

I have a TVertScrollBox and I have some components inside it. One of them is a TListBox witch has some TListBoxItem.

That TListBox has the size of all of its items. So it doesn't have a scrollbar.

I need that the scroll gesture over TListBox goes to TVertScrollBox. When I try to scroll in a listbox it do not scroll itself nor its parent.

It only can be tested in mobile. In windows we can not simulate, once mouse wheel is not the same event of scrooling by touching.

I already tried to send the events to its parent but it hasn't worked so far.

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.StdCtrls, FMX.ListBox,
  FMX.Layouts;

type
  TForm1 = class(TForm)
    Button1: TButton;
    VertScrollBox1: TVertScrollBox;
    ListBox1: TListBox;
    ListBoxItem1: TListBoxItem;
    ListBoxItem2: TListBoxItem;
    ListBoxItem3: TListBoxItem;
    ListBoxItem4: TListBoxItem;
    ListBoxItem5: TListBoxItem;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

end.
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 480
  ClientWidth = 400
  FormFactor.Width = 320
  FormFactor.Height = 480
  FormFactor.Devices = [Desktop]
  DesignerMasterStyle = 0
  object VertScrollBox1: TVertScrollBox
    Position.X = 48.000000000000000000
    Position.Y = 80.000000000000000000
    Size.Width = 273.000000000000000000
    Size.Height = 313.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 1
    Viewport.Width = 257.000000000000000000
    Viewport.Height = 313.000000000000000000
    object Button1: TButton
      Position.X = 104.000000000000000000
      Position.Y = 352.000000000000000000
      TabOrder = 1
      Text = 'Button1'
    end
    object ListBox1: TListBox
      Position.X = 24.000000000000000000
      Position.Y = 24.000000000000000000
      Size.Width = 200.000000000000000000
      Size.Height = 241.000000000000000000
      Size.PlatformDefault = False
      TabOrder = 2
      DisableFocusEffect = True
      DefaultItemStyles.ItemStyle = ''
      DefaultItemStyles.GroupHeaderStyle = ''
      DefaultItemStyles.GroupFooterStyle = ''
      Viewport.Width = 196.000000000000000000
      Viewport.Height = 237.000000000000000000
      object ListBoxItem1: TListBoxItem
        TabOrder = 0
        Text = 'ListBoxItem1'
      end
      object ListBoxItem2: TListBoxItem
        Position.Y = 19.000000000000000000
        TabOrder = 1
        Text = 'ListBoxItem2'
      end
      object ListBoxItem3: TListBoxItem
        Position.Y = 38.000000000000000000
        TabOrder = 2
        Text = 'ListBoxItem3'
      end
      object ListBoxItem4: TListBoxItem
        Position.Y = 57.000000000000000000
        TabOrder = 3
        Text = 'ListBoxItem4'
      end
      object ListBoxItem5: TListBoxItem
        Position.Y = 76.000000000000000000
        TabOrder = 4
        Text = 'ListBoxItem5'
      end
    end
  end
end

Upvotes: 2

Views: 401

Answers (1)

Robson Benedito
Robson Benedito

Reputation: 145

Thanks for Tom Brunberg, I finally got the solution.

I just needed to disable the rotate value from interactiveGestures doing:

listBox.Touch.InteractiveGestures := [];

By default it set to true.

Upvotes: 1

Related Questions