0

在 FiremonkeyTListview中滚动条的可见性取决于系统是否有触摸屏。当列表视图上没有足够空间显示所有列表项时,如何覆盖此行为并始终显示垂直滚动?

我在里面看到TListViewBase.Create滚动可见性再次取决于函数结果,HasTouchTracking这取决于是否TScrollingBehaviour.TouchTracking设置在SystemInformationService.GetScrollingBehaviour.

有没有人有胶水我可以如何覆盖这种行为?

4

2 回答 2

2

不久前,我“拼凑”(匆忙地)这个单元来覆盖 Windows 的 GetScrollingBehaviour。您可以为要覆盖它的任何平台执行类似的操作。在 Create 方法中,我删除了已安装的服务,但为未被覆盖的部分保留对它的引用,然后用我自己的替换它。

unit DW.ScrollingBehaviourPatch.Win;

// This unit is used for testing of "inertial" scrolling of listviews etc on devices that do not have touch capability

interface

implementation

uses
  FMX.Platform;

type
  TPlatform = class(TInterfacedObject, IFMXSystemInformationService)
  private
    class var FPlatform: TPlatform;
  private
    FSysInfoService: IFMXSystemInformationService;
  public
    { IFMXSystemInformationService }
    function GetScrollingBehaviour: TScrollingBehaviours;
    function GetMinScrollThumbSize: Single;
    function GetCaretWidth: Integer;
    function GetMenuShowDelay: Integer;
  public
    constructor Create;
    destructor Destroy; override;
  end;

{ TPlatform }

constructor TPlatform.Create;
begin
  inherited;
  if TPlatformServices.Current.SupportsPlatformService(IFMXSystemInformationService, FSysInfoService) then
    TPlatformServices.Current.RemovePlatformService(IFMXSystemInformationService);
  TPlatformServices.Current.AddPlatformService(IFMXSystemInformationService, Self);
  FPlatform := Self;
end;

destructor TPlatform.Destroy;
begin
  //
  inherited;
end;

function TPlatform.GetCaretWidth: Integer;
begin
  Result := FSysInfoService.GetCaretWidth;
end;

function TPlatform.GetMenuShowDelay: Integer;
begin
  Result := FSysInfoService.GetMenuShowDelay;
end;

function TPlatform.GetMinScrollThumbSize: Single;
begin
  Result := FSysInfoService.GetMinScrollThumbSize;
end;

function TPlatform.GetScrollingBehaviour: TScrollingBehaviours;
begin
  Result := [TScrollingBehaviour.Animation, TScrollingBehaviour.TouchTracking];
end;

initialization
  TPlatform.Create;

end.
于 2019-10-31T21:10:23.437 回答
0

对于 Dave 提出的解决方法,触摸跟踪需要关闭,如下所示:

function TPlatformListViewWorkaround.GetScrollingBehaviour: TScrollingBehaviours;
begin
  result := fSysInfoService.GetScrollingBehaviour - [TScrollingBehaviour.TouchTracking];
end;

但是,使用此解决方案,您必须接受无法再用手指滚动触摸屏系统上的列表视图。

这就是为什么我现在在 Embarcadero Quality Central 中打开了一个更改请求,并通过使用新属性 SuppressScrollBarOnTouchSystems (RSP-26584) 扩展 TListView 来提出解决方案建议。

于 2019-11-06T10:28:17.833 回答