不久前,我“拼凑”(匆忙地)这个单元来覆盖 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.