TChangeTabAction FMX XE7 – what were Embarcadero thinking?

  

After adding a standard action of TChangeTabAction to my actionlist,
I have written a function like this:

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

which I call like this:

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

and later

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

And I’m still trying to figure out how to add the Reverse = True functionality to my function!

The problem is, with each call to ChangeTabAction1.ExecuteTarget(Self);, the ChangeTabAction1.Direction is automatically reversed! (toggled)

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.

What I want it to do is

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

and later

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

My Tabcontrol app. is much more complex than this simple 3 level example. I want to be able to control the direction of the shift on command.

The ChangeTabAction1.Direction indicator doesn’t have any meaning in the usual sense. You can’t set it to Reverse and think that means the opposite of normal. Reverse becomes Normal immediately after executetarget and vice-versa.

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;

Perhaps, if someone can tell me what the Embarcadero designers were thinking here, then I can follow their design idea instead of trying to work around it.

Comments are closed.