滚动与选择Delphi XE6 [英] scrolling vs selecting delphi XE6
问题描述
我有一个gridpanellayout,它大约有16行5列.每个字段都有一个设置为TalignLayout.Client的TRectangle.每个矩形都有一个onclick事件,该事件执行一个操作(例如,通过更改其颜色来突出显示所单击的矩形).有16行,我的网格面板超过了诸如iPhone之类的用户设备的高度,因此我将网格放置在VerticalScrollbox的顶部.
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.
有什么建议吗?
推荐答案
我的建议和解决方法是使用MouseDown和MouseDown事件,并在两者之间进行一些时间测量.
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.
如果时间少于200毫秒,建议您进行手指触摸,那么您应该走了.
If the time past less then 200 ms an Finger Touch is suggested and you should good to go.
这篇关于滚动与选择Delphi XE6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!