3

将 TChangeTabAction 的标准操作添加到我的操作列表后,我编写了如下函数:

procedure TfrmMain.ChangeTab(TargetTab: TTabItem; Reverse: Boolean = False);
begin
  ChangeTabAction1.Tab := TargetTab;
  ChangeTabAction1.ExecuteTarget(Self);
end;

我这样称呼:

 ChangeTab(tsNewTemplate) // slides left
 // stuff
 ChangeTab(tsLogin); // slides right

然后

ChangeTab(tsNewTemplate, True); // slides left
// stuff
ChangeTab(tsLogin, True); // slides right

而且我仍在试图弄清楚如何将 Reverse = True 功能添加到我的函数中!

问题是,每次调用ChangeTabAction1.ExecuteTarget(Self);ChangeTabAction1.Direction都会自动反转!(切换)

So when the tab changes from tsStartUp to tsNewTemplate, it shifts to the left, then it shifts to the right, then to the left and right and so on.

我想要它做的是

ChangeTab(tsNewTemplate) // slides left
// stuff
 ChangeTab(tsLogin); // slides left

然后

ChangeTab(tsNewTemplate, True); // slides right
// stuff
ChangeTab(tsLogin, True); // slides right

我的 Tabcontrol 应用程序。比这个简单的 3 级示例要复杂得多。我希望能够根据命令控制换档的方向。

ChangeTabAction1.Direction 指示器在通常意义上没有任何意义。您不能将其设置为 Reverse 并认为这意味着与正常相反。反转之后立即变为正常,executetarget反之亦然。

procedure TfrmMain.ChangeTab(TargetTab: TTabItem; Reverse: Boolean = False);
begin
    // This keeps the slide direction going the same way
    // It cancels out the automatic reversal of direction
    if ChangeTabAction1.Direction = TTabTransitionDirection.Normal then
      ChangeTabAction1.Direction := TTabTransitionDirection.Reversed
    else
      ChangeTabAction1.Direction := TTabTransitionDirection.Normal; 

也许,如果有人能告诉我 Embarcadero 设计师在这里的想法,那么我可以遵循他们的设计理念,而不是试图绕过它。

4

1 回答 1

2

TTabTransitionDirection.Normal 意味着对具有较低索引的选项卡的更改是通过从左到右的转换完成的,而对具有较高索引的选项卡的更改是通过从右到左的转换完成的。TTabTransitionDirection.Reversed 意味着相反。

于 2015-04-28T07:09:32.293 回答