首先说一下这个功能已经有了例程,在
C:\Users\Public\Documents\Embarcadero\Studio\16.0\Samples\CPP\Mobile Samples\User Interface\TabSlideTransition
里面。
我根据此例程琢磨着如何把此功能为己所用,现在已解决。
我们从设置好TabConrol开始。首先,添加ActionList控件,如图。
双击该控件,在弹出的菜单栏做如下设置:
NextTabAction就是下一个Tab的意思啦,PreviousTabAction是上一个Tab。
设置好ActionList后还没有完成,这只是实现了动作,还没有实现识别左滑和右滑手势,下面添加GestureManager控件,如图:
有了这个控件就可以识别手势了。
接下来,我们给TabControl添加动作,在OnGesture中添加代码,如图:
代码如下:
void __fastcall THeaderFooterForm::TabControlGesture(TObject *Sender, const TGestureEventInfo &EventInfo, bool &Handled) { switch (EventInfo.GestureID) { case sgiLeft: TabControl->Next(TTabTransition::Slide, TTabTransitionDirection::Normal); Handled = true; break; case sgiRight: TabControl->Previous(TTabTransition::Slide, TTabTransitionDirection::Normal); Handled = true; break; default: break; } }
Delphi 预定义了 34 种标准手势, 并定义成 TStandardGesture 枚举类型:
TStandardGesture = ( sgLeft = sgiLeft, sgRight = sgiRight, sgUp = sgiUp, sgDown = sgiDown, sgUpLeft = sgiUpLeft, sgUpRight = sgiUpRight, sgDownLeft = sgiDownLeft, sgDownRight = sgiDownRight, sgLeftUp = sgiLeftUp, sgLeftDown = sgiLeftDown, sgRightUp = sgiRightUp, sgRightDown = sgiRightDown, sgUpDown = sgiUpDown, sgDownUp = sgiDownUp, sgLeftRight = sgiLeftRight, sgRightLeft = sgiRightLeft, sgUpLeftLong = sgiUpLeftLong, sgUpRightLong = sgiUpRightLong, sgDownLeftLong = sgiDownLeftLong, sgDownRightLong = sgiDownRightLong, sgScratchout = sgiScratchout, sgTriangle = sgiTriangle, sgSquare = sgiSquare, sgCheck = sgiCheck, sgCurlicue = sgiCurlicue, sgDoubleCurlicue = sgiDoubleCurlicue, sgCircle = sgiCircle, sgDoubleCircle = sgiDoubleCircle, sgSemiCircleLeft = sgiSemiCircleLeft, sgSemiCircleRight = sgiSemiCircleRight, sgChevronUp = sgiChevronUp, sgChevronDown = sgiChevronDown, sgChevronLeft = sgiChevronLeft, sgChevronRight = sgiChevronRight);
设置好了左滑和右滑的动作,下面是最后一步:
按图找到该位置,给Left和Right打钩。完成!
参考资料:
http://www.cnblogs.com/del/archive/2009/10/21/1587265.html