Skip to content

Using TabControls, Gestures and Actions in your C++Builder XE5 for iOS apps

This C++ for iOS video shows you how to use TabControls, Gestures and Actions in the UI of your iOS apps using C++Builder XE5. You start by creating a FM Mobile application for C++Builder using the Tabbed mobile project template.

The Tabbed template will create a starting mobile app using a TabControl with 4 tab items. Add a TGestureManager and TActionList to the application.  Then I create the UI for each of the TabItems, in my case I just put a TLabel on each of the TabItem’s client area. I create two ActionList items using the TChangeTabAction standard action class, one to select the previous TabItem and one to select the next TabItem. Then I set the TabControl’s Touch property’s GestureManager property. I select the Left Gesture and associate the LeftAction to the left gesture and the RightAction to the right gesture.  Add a little code to handle the changing of the active TabItem for both of the actions.  Finally, I compile and run the C++Builder application on my iPhone 4S.

Here is the code inside the main unit for the Form’s OnCreate event handler (this code is generated by the Tabbed project template:

void __fastcall TTabbedForm::FormCreate(TObject *Sender)
{
	// Make sure that the first tab item is the active tab on startup
	TabControl1->ActiveTab = TabItem1;
}

Here is the code for the event handlers for my Left Action/Gesture and my Right Action/Gesture:

void __fastcall TTabbedForm::ChangeTabActionLeftUpdate(TObject *Sender)
{
  // Left Gesture - Tab Slide Left unless at the first tab
  if (TabControl1->TabIndex > 0) {
	ChangeTabActionLeft->Tab = TabControl1->Tabs[TabControl1->TabIndex-1];
  }
  else {
	ChangeTabActionLeft->Tab = nil;
  }
}

void __fastcall TTabbedForm::ChangeTabActionRightUpdate(TObject *Sender)
{
  // Right Gesture - Tab Slide Right unless at the last tab
  if (TabControl1->TabIndex < TabControl1->TabCount-1) {
	 ChangeTabActionRight->Tab = TabControl1->Tabs[TabControl1->TabIndex+1];
  }
  else {
	 ChangeTabActionRight->Tab = nil;
  }
}

For additional information about C++Builder for iOS go to the product information page - http://www.embarcadero.com/products/cbuilder/ios-development

Special Offer: Get a free C++Builder iOS upgrade when you buy qualifying C++Builder XE5 or RAD Studio XE5 tools

C++Builder for iOS is coming soon (expected December 2013). Very soon, you will be able to create iOS apps with C++Builder! Get started with the latest version of C++Builder or RAD Studio today to benefit from the fastest, visual, multi-device app development solution for Windows and OS X, and be one of the first to deliver C++Builder apps on iOS.

Watch the C++Builder for iOS Preview at http://www.youtube.com/watch?v=EwHJbB0Zi0g

Buy one of these qualifying tools now and get the C++Builder iOS upgrade FREE as soon as it is available:

  • C++Builder XE5 – Enterprise, Ultimate or Architect editions only
  • RAD Studio XE5 – all editions

This offer is not available for C++Builder Professional edition or Starter edition.

How to get it: Purchase one of the qualifying products, new user or upgrade. When C++Builder iOS support is released, you will gain access to iOS features in a free downloadable upgrade to your XE5 product.
Exceptions: Does not apply to C++Builder Professional or Starter edition.

Availability: Buy now. The iOS upgrade will be available to all C++Builder XE5 Ent/Ult/Arch registered users and all RAD Studio XE5 users. This offer can be combined with the "Upgrade from any earlier version", "Bonus Pack" and "Step Up to Ultimate" offers.

Post a Comment

Your email is never published nor shared. Required fields are marked *

Bad Behavior has blocked 4 access attempts in the last 7 days.

Close