Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
Option Explicit Public Sub Form_Load() 'omit Frame1 from tab sequence: Frame1.Parent.setFocusable(False) End Sub Public Sub OptTabOrder1_Click() Dim myTabOrder As New TabOrder 'either build up the tab sequence by adding the 'components to the taborder consecutively myTabOrder.Add(OptionBox1) myTabOrder.Add(OptionBox2) myTabOrder.Add(OptionBox3) myTabOrder.Add(OptionBox4) myTabOrder.Add(CheckBox4) myTabOrder.Add(CheckBox3) myTabOrder.Add(CheckBox2) myTabOrder.Add(CheckBox1) Form1.Parent.setFocusTraversalPolicy(myTabOrder) End Sub Public Sub OptTabOrder2_Click() Dim myTabOrder As New TabOrder(1, 8)' (LBound To UBound) 'optionally build up the tab sequence by using the 'TabIndex property myTabOrder.TabIndex(OptionBox1) = 1 myTabOrder.TabIndex(OptionBox2) = 4 myTabOrder.TabIndex(OptionBox3) = 5 myTabOrder.TabIndex(OptionBox4) = 8 myTabOrder.TabIndex(CheckBox1) = 2 myTabOrder.TabIndex(CheckBox2) = 3 myTabOrder.TabIndex(CheckBox3) = 6 myTabOrder.TabIndex(CheckBox4) = 7 Form1.Parent.setFocusTraversalPolicy(myTabOrder) End Sub Public Sub OptTabDefault_Click() Form1.Parent.setFocusTraversalPolicy(Nothing) End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
Option Explicit Dim myLBound As Integer Dim myOrder As New java#util#Vector Public Sub TabOrder() End Sub Public Sub TabOrder(iLBound As Integer, iUBound As Integer) myLBound = iLBound myOrder.setSize(iUBound - myLBound + 1) End Sub Public Sub Add(ctrl As Component) myOrder.add(ctrl) End Sub Public Property Get TabIndex(ctrl As Component) As Integer TabIndex = myOrder.indexOf(ctrl) + myLBound End Property Public Property Let TabIndex(ctrl As Component, Index As Integer) Index = Index - myLBound If Index >= Count Then Add(ctrl) Else myOrder.setElementAt(ctrl, Index) End If End Property Public Property Get Count() As Integer Count = myOrder.size End Property ' ########## ' FocusTraversalPolicy ' ########## ' Private Function getNext(direction As Integer, _ aComponent As Component) As Component If Count > 0 Then Dim Index As Integer = (myOrder.indexOf(aComponent) + direction) Dim cmp As Component, cnt As Integer ' this do loop is an intelligence for error tolerance ;) Do While (cmp = Nothing) And (cnt < Count) If Index = Count Then Index = 0 If Index < 0 Then Index = Count - 1 cmp = Cast(myOrder.get(Index), Component) Index = Index + direction cnt = cnt + 1 Loop getNext = cmp End If End Function Public Function getComponentAfter(focusCycleRoot As Container, _ aComponent As Component) As Component getComponentAfter = getNext(+1, aComponent) End Function Public Function getComponentBefore(focusCycleRoot As Container, _ aComponent As Component) As Component getComponentBefore = getNext(-1, aComponent) End Function Public Function getDefaultComponent(focusCycleRoot As Container) As Component getDefaultComponent = getFirstComponent(focusCycleRoot) End Function Public Function getLastComponent(focusCycleRoot As Container) As Component getLastComponent = Cast(myOrder.lastElement, Component) End Function Public Function getFirstComponent(focusCycleRoot As Container) As Component getFirstComponent = Cast(myOrder.firstElement, Component) End Function |
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Quoted
included in IDE and framework ... Each control could have a TabIndex() property
Quoted
The initialization of Form, Dialog or Usercontrol would then automatically
setup the appropriate tab order according to TabIndex values
Quoted
Controls without TabIndex or with the same TabIndex value are sorted according to their name
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<Object Type="VB/TextBox"> <Param Name="Index" Value="" /> <Param Name="BorderStyle" Value="fmBorderStyleSingle" /> <Param Name="HScrollBar" Value="sbShowNever" /> <Param Name="VScrollBar" Value="sbShowNever" /> <Param Name="Text" Value="Text1" /> <Param Name="BackColorSel" Value="-2147483635" /> <Param Name="ForeColorSel" Value="-2147483634" /> <Param Name="MultiLine" Value="False" /> <Param Name="TabSize" Value="4" /> <Param Name="ForwardTab" Value="True" /> <Param Name="Locked" Value="False" /> <Param Name="FontName" Value="Arial" /> <Param Name="FontBold" Value="False" /> <Param Name="FontItalic" Value="False" /> <Param Name="FontSize" Value="9" /> <Param Name="BackColor" Value="-2147483643" /> <Param Name="ForeColor" Value="-2147483640" /> <Param Name="Width" Value="161" /> <Param Name="Height" Value="57" /> <Param Name="Left" Value="80" /> <Param Name="TabIndex" Value="80" /> <<<<<<<---------------------- <Param Name="Top" Value="80" /> <Param Name="ToolTip" Value="" /> <Param Name="Enabled" Value="True" /> <Param Name="Visible" Value="True" /> <Param Name="Tag" Value="" /> <Param Name="MousePointer" Value="vbDefault" /> <Param Name="MouseIcon" Value="Nothing" /> <Param Name="CanGetFocus" Value="True" /> <Param Name="(Name)" Value="Text1" /> </Object> |
Quoted
I have to confess that I am no real TabIndex-Expert
OK sounds reasonable.Quoted
... but it has the benefit of being clear and unique.
And it is easy to rename controls and thus achieve a reordering
Quoted
In doubt I would prefer to get the VB6 style in Jabaco
Jabaco Source |
|
1 2 3 4 5 |
Enum JabacoTabStop VB6TabStop = -1 ' (True) compatible when importing VB6-Projects TabStopFalse = 0 ' the component is excluded from TabStops SwingDefaultFocusPolicy = 1 ' for new Jabaco project (nothing has to be done) End Enum |
Quoted
Jabaco should invent own improvements only if there are convincing reasons
Quoted
Which attributes of a control are actually taken into consideration in the Jabaco IDE property dialog?