What You Need To Know About TabOrder And Cross Platform Apps
Developers often get requests to create forms where it is crucial to pay attention to the position of a cursor after the Tab key is pressed at every point of the program execution. This can be particularly important when developing cross platform apps where following user’s expectations of how user interfaces should behave can help make your app seem professional. It can be important from different perspectives, including user experience, client’s requirements, and important things like functionality. Delphi provides wide opportunities for this thanks to the implementation of the “TabOrder” property. In this article, we offer you to take a closer look at the TabOrder property in Delphi, to analyze how it’s supported, how it can be used and to see whether there are any limitations. What is a taborder and what does it do? The TabOrder property has been a part of Delphi since the release of Delphi 1. In earlier versions of Delphi, TabOrder was a part of the VCL hierarchy while in newer versions it is a part of FMX with small changes in the hierarchy. When the Tab key is pressed, the focus moves from one control to the next one. Due to the peculiarities of their design, not all controls can receive focus (E.g. TLabel) and not all controls can participate in the tab navigation. Even controls that can receive focus must be explicitly included in the tab sequence. In VCL, TabOrder is defined in the TWinControl class that normally unites components that are derived ultimately from the TWinControl class and will have the TabOrder property. Below you can see a typical declaration of the TabOrder property in the TWinControl class. property TabOrder: TTabOrder read GetTabOrder write SetTabOrder; TTabOrder is defined as an Enumeration that can contain values from -1 to 32767. Controls with a TabOrder value that equals -1 will be skipped during the Tab Ordering when the tab key is pressed. How is taborder different in a cross-platform app? In FMX, TabOrder is a part of the TControl class and is declared similar to the TWinControl class in VCL as described above. There is one more property named TabStop which determines whether a control will receive focus or not depending on the TabStop property value. Controls with a TabStop value that is False will not receive focus regardless of their TabOrder value. This principle is similar to the cases when the TabOrder value equals -1. As per the Embarcadero documentation, the TabOrder property is indicated as the position of the control in its parent’s tab order. This means that each parent control will have its own list of Tab Orders. An ultimate parent form that has all controls sitting over it also contains a list of tab orders for all controls (except the ones which are children of other controls on the same form). The control on the parent form which has a TabOrder set to 0 will have focus when the form first appears. Initially, when you create components at the design time, the tab order is always the order in which controls were added to the form. The first control added to the form has a TabOrder value of 0, the second one’s value equals 1, the third one has a value of 2, and so on. As we have seen […]
