scrolling vs selecting delphi XE6

徘徊边缘 提交于 2019-12-25 03:26:23

问题


I have a gridpanellayout that has about 16 rows and 5 columns. Each field has, for example a TRectangle set to TalignLayout.Client.. Each rectangle has an onclick event that performs an action ( e.g., highlighting the clicked rectangle by changing its color ). With 16 rows, my gridpanel exceeds the height of a user device such as an iPhone, and so i have the Grid placed on top of a VerticalScrollbox.

What would be the best way to decipher between a user using a finger to scroll, vs using touch to highlight an item. I supposed to easiest option I've thought of it simply changing an on click event to a double click event.

Any suggestions?


回答1:


My suggestion and workaround is use the MouseDown and the MouseDown Events with a bit of time measurement in between.

unit UnitMainForm;

interface

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

  type
  TForm1 = class(TForm)
    VertScrollBox1: TVertScrollBox;
    GridPanelLayout1: TGridPanelLayout;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Button10: TButton;
    Button11: TButton;
    Button12: TButton;
    procedure Button1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Single);
    procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Single);
  private
    { Private-Deklarationen }
    FTimeStamp: TDateTime;
      public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

uses
  System.DateUtils;

procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
  FTimeStamp := Now;
  TButton(Sender).Text := 'Mouse Down';
end;

procedure TForm1.Button1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
  TButton(Sender).Text := 'Mouse Up ' + IntToStr(MilliSecondOf(Now-FTimeStamp));
  if (MilliSecondOf(Now-FTimeStamp) < 200) then
  begin
    TButton(Sender).Text := TButton(Sender).Text + ' OK';
  end;
end;

end.   

If the time past less then 200 ms an Finger Touch is suggested and you should good to go.



来源:https://stackoverflow.com/questions/24681940/scrolling-vs-selecting-delphi-xe6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!