You are not logged in.

Roger L

Beginner

  • "Roger L" started this thread

Posts: 24

Date of registration: Apr 12th 2010

  • Send private message

1

Thursday, May 6th 2010, 3:22am

Tab Sequence

Hi,

I have a data entry form on which I am trying to set the tab sequence. By default it is going forwards through the controls - top to bottom, left to right - which is a good starting point. What I want to do is to omit things like labels from the tab sequence. I can't find a way to do this. There doesn't seem to be a TabIndex property on the controls.

Any help much appreciated!

Rgds

Roger L

ps I am rediscovering VB6 as a great environment - but even more powerful when backed by Java - have used SQLite up until now but H2 is quite something!

Roger L

Beginner

  • "Roger L" started this thread

Posts: 24

Date of registration: Apr 12th 2010

  • Send private message

2

Saturday, May 8th 2010, 1:14am

Hi,

Suprised there was no-one who could help me on what I thought was a fairly simple and basic, but important, topic in the usability of data entry screens, I have managed to roughly solve my problem by using the 'CanGetFocus' property of the controls on my screen - but its not exactly what I wanted and I'm sure there must be a better way. I guess I must investigate Swing a little more - but surely I won't have to drop back to java code for this!

Roger L

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

3

Saturday, May 8th 2010, 1:08pm

Yes, you are right. There is probably no easy solution.

I've found the following link on Swing Focus Traversal Policy.

It look like a major extension to the Jabaco framework to get this implemented.
Comparing the simple Tabindex approach of VB6 to the convoluted solution of Swing,
I consider this another example for why Swing should be hidden from 95% of all developers.

Please let us know your solution.

Greetings

A1880

Roger L

Beginner

  • "Roger L" started this thread

Posts: 24

Date of registration: Apr 12th 2010

  • Send private message

4

Sunday, May 9th 2010, 12:02am

Thanks for the suggestion - I'll have a look at it. What I suspect I will have to do is specifically program my data entry field sequence by putting in some code to set the focus to the next field as each field loses the focus (It's a good spot to put in the field validation code anyway).

Roger L

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

5

Monday, May 10th 2010, 11:26am

Omit Label from tab sequence

Exclude a control (Label) from the tab sequence.

Jabaco Source

1
2
3
Sub Form_Load()
   Label1.Parent.setFocusable(False)
End Sub


the control is no longer reachable by using the Tab-key on your keyboard.



regards

OlimilO

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

6

Monday, May 10th 2010, 6:08pm

TabOrder

Hello forum,
thanks to A1880 for the very useful link, I made a tiny little example and a handy class hopefully to get a grip on the TabOrder-problem.
Form: Form1 with a few Controls see the screenshot below

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


Class TabOrder: SuperClass: java#awt#FocusTraversalPolicy

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


regards

OlimilO
OlimilO has attached the following images:
  • TO_1.png
  • TO_2.png

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

7

Tuesday, May 11th 2010, 9:14am

Cool! :thumbup:

That is useful indeed.

My dream would be to get this included in IDE and framework.
I would like to use the old TabIndex() paradigm of VB6 without worrying about extra classes and other complications.
Each control could have a TabIndex() property. The initialization of Form, Dialog or Usercontrol would then automatically
setup the appropriate tab order according to TabIndex values.
Controls without TabIndex or with the same TabIndex value are sorted according to their name.

Greetings

A1880

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

8

Tuesday, May 11th 2010, 10:21am

thanks. it's just one solution of many, to a problem though



Quoted

included in IDE and framework ... Each control could have a TabIndex() property

it's no big deal to spent two new properties TabIndex (Integer) and TabStop (Boolean) to every Jabaco-control. But the VB-IDE does even more. whenever you set the TabIndex in the property-editor, the VB-IDE checks

A) the maxindex, and

B) sets the TabIndex of all other controls accordingly.

e.g. TabStop by default is true to all controls so all controls on one form must have a TabIndex.

->A) if you have 10 controls on the form it's not possible to set TabIndex = 20.

->B) if you want to set the TabIndex of all your controls you have to take care it's a bit tricky

I always had problems in setting the TabIndex in the VB-IDE.

it's a kind of logic, should the Jabaco-IDE mimic this behaviour too, even if it could be much better and easier?

moreover, Swing and VB do not have the same behaviour for OptionButtons. in VB the OptionButtons are grouped together in one TabStop whereas in Jabaco every OptionBox has it's own TabStop.

Quoted

The initialization of Form, Dialog or Usercontrol would then automatically
setup the appropriate tab order according to TabIndex values

this is possible already if we integrate the TabOder-class into the Jabaco-Framework, the Jabaco-IDE must only check the MaxIndex.


Quoted

Controls without TabIndex or with the same TabIndex value are sorted according to their name

sorted by name... :?:

hmm, that's a different behaviour than the VB-IDE has. could you please make a more detailed explanation or a suggestion by code.



regards

OlimilO

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

9

Tuesday, May 11th 2010, 1:37pm

Thanks for your explanations. I have to confess that I am no real TabIndex-Expert.

VB6 assigns TabIndex values in an incremental fashion whenever a new control is inserted.
Therefore, the easiest way for the VB6 developer is to insert the controls in the required Tab order.

My suggestion to use the names might not be ideal, but it has the benefit of being clear and unique.
And it is easy to rename controls and thus achieve a reordering.
I haven't tried what happens in VB6 if you assign identical TabIndex values to several controls.

In doubt I would prefer to get the VB6 style in Jabaco.
Jabaco should invent own improvements only if there are convincing reasons.

Greetings

A1880

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

10

Tuesday, May 11th 2010, 2:38pm

Which attributes of a control are actually taken into consideration in the Jabaco IDE property dialog?
Is this a hard-coded list of properties or can this be influenced by changing the framework or some XML file?

In other words:
Do we need an IDE update to get the TabIndex property properly handled by the IDE?
Well, I think we do need an update.

By adding an additional TabIndex parameter to the param list of Form1.jsrc, I've fooled
the IDE. It now shows the TabIndex property in the property dialog for my Textbox:

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>


Obviously, this is good for nothing.
The TabIndex property appears in the list but does not influence the generated code.

Greetings

A1880

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

11

Tuesday, May 11th 2010, 3:58pm

Quoted

I have to confess that I am no real TabIndex-Expert

me neither, in fact you will get one if you dive deeper ;)



Quoted

... but it has the benefit of being clear and unique.
And it is easy to rename controls and thus achieve a reordering
OK sounds reasonable.

Quoted

In doubt I would prefer to get the VB6 style in Jabaco

Suggestion: Property TabStop As JabacoTabStop

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

Yes also my opinion. The existing solution adopted from Swing is a convincing solution and it's not an own improvment.

Quoted

Which attributes of a control are actually taken into consideration in the Jabaco IDE property dialog?

good question, looking forward to hearing from Manuel


regards

OlimilO

Rate this thread
WoltLab Burning Board