default behavour tabing; not yet configurable (next step) rel3_6_1
authorca
Tue, 01 Feb 2000 14:53:30 +0100
changeset 1665 51c444bfe5ae
parent 1664 a8b97314f813
child 1666 cbeea1429021
default behavour tabing; not yet configurable (next step)
DSVColumnView.st
--- a/DSVColumnView.st	Tue Feb 01 13:15:45 2000 +0100
+++ b/DSVColumnView.st	Tue Feb 01 14:53:30 2000 +0100
@@ -441,6 +441,10 @@
     ]
 !
 
+handleTab
+    ^ true
+!
+
 multipleSelectOk
     "allow/disallow multiple row selections; the default is false
     "
@@ -1992,7 +1996,7 @@
                           #BeginOfText #EndOfText #ScrollUp #ScrollDown
                           #CursorUp #CursorDown #CursorRight #CursorLeft)>
 
-    |sensor n max idx selRowNr key column isTab listSize noSel|
+    |sensor n maxColNr idx selRowNr key column isTab listSize noSel|
 
     (sensor := self sensor) isNil ifTrue:[
         ^ self
@@ -2036,38 +2040,56 @@
         ].
         ^ self selectColIndex:selectedColIndex rowIndex:n
     ].
-    (isTab := aKey includesString:'Tab') ifTrue:[
-        key := (sensor shiftDown or:[aKey includesString:'Left']) ifTrue:[#CursorLeft]
-                                                                 ifFalse:[#CursorRight]
-    ] ifFalse:[
-        (aKey == #focusPrevious or:[aKey == #focusNext]) ifTrue:[
-            isTab := true.
-            key   := aKey == #focusPrevious ifTrue:[#CursorLeft] ifFalse:[#CursorRight]
+
+    (aKey == #CursorLeft or:[aKey == #CursorRight]) ifFalse:[
+        self handleTab ifFalse:[
+            ^ super keyPress:aKey x:x y:y
+        ].
+
+        (aKey includesString:'Tab') ifTrue:[
+            key := (sensor shiftDown or:[aKey includesString:'Left']) ifTrue:[#CursorLeft]
+                                                                     ifFalse:[#CursorRight]
         ] ifFalse:[
-            (aKey == #CursorRight or:[aKey == #CursorLeft]) ifFalse:[
+            (aKey == #FocusPrevious or:[aKey == #FocusNext]) ifFalse:[
                 ^ super keyPress:aKey x:x y:y
             ].
-            key := aKey
+            key := aKey == #FocusPrevious ifTrue:[#CursorLeft] ifFalse:[#CursorRight].
+        ].
+        isTab := true.
+    ] ifTrue:[
+        isTab := false.
+        key   := aKey.
+    ].
+
+    isTab ifTrue:[
+        selRowNr == 0 ifTrue:[
+            self tabIn ifFalse:[
+                ^ super keyPress:aKey x:x y:y
+            ].
         ]
     ].
-    max := self numberOfColumns.
-    selRowNr == 0 ifTrue:[selRowNr := 1].
-
-    (idx := selectedColIndex) == 0 ifTrue:[
-        idx := key == #CursorRight ifTrue:[0] ifFalse:[max + 1]
-    ].
+    maxColNr := self numberOfColumns.
+    idx := selectedColIndex.
 
     key == #CursorLeft ifTrue:[
+        selRowNr == 0 ifTrue:[selRowNr := listSize].
+        idx      == 0 ifTrue:[idx      := maxColNr + 1].
+
         [n ~~ 0] whileTrue:[
-            (idx := idx - 1) == 0 ifTrue:[
-                (isTab and:[(selRowNr := selRowNr - 1) == 0]) ifTrue:[
-                    tabAtStartAction notNil ifTrue:[
-                        tabAtStartAction value
-                    ] ifFalse:[
-                        self windowGroup focusPreviousFrom:self
+            idx := idx - 1.
+            idx == 0 ifTrue:[
+                (selRowNr := selRowNr - 1) == 0 ifTrue:[
+                    isTab ifTrue:[
+                        tabAtStartAction notNil ifTrue:[
+                            tabAtStartAction value
+                        ] ifFalse:[
+                            self deselect.
+                            self windowGroup focusPreviousFrom:self
+                        ]
                     ].
+                    ^ self
                 ].
-                ^ self
+                idx := maxColNr
             ].
             column := self columnAt:idx.
 
@@ -2076,16 +2098,24 @@
             ]
         ]
     ] ifFalse:[
+        selRowNr == 0 ifTrue:[selRowNr := 1].
+
         [n ~~ 0] whileTrue:[
-            (idx := idx + 1) > max ifTrue:[
-                (isTab and:[(selRowNr := selRowNr + 1) > listSize]) ifTrue:[
-                    tabAtEndAction notNil ifTrue:[
-                        tabAtEndAction value
-                    ] ifFalse:[
-                        self windowGroup focusNextFrom:self
+            idx := idx + 1.
+
+            idx > maxColNr ifTrue:[
+                (selRowNr := selRowNr + 1) > listSize ifTrue:[
+                    isTab ifTrue:[
+                        tabAtEndAction notNil ifTrue:[
+                            tabAtEndAction value
+                        ] ifFalse:[
+                            self deselect.
+                            self windowGroup focusNextFrom:self
+                        ]
                     ].
+                    ^ self
                 ].
-                ^ self
+                idx := 1
             ].
             column := self columnAt:idx.
 
@@ -2108,6 +2138,19 @@
     self updateEditViewOrigin.
 ! !
 
+!DSVColumnView methodsFor:'focus handling'!
+
+canTab
+    super canTab ifTrue:[
+        ^ editView isNil
+    ].
+    ^ false
+!
+
+tabIn
+    ^ true
+! !
+
 !DSVColumnView methodsFor:'gc operations'!
 
 imageOnDevice:anImage
@@ -3084,7 +3127,7 @@
     "change selection without notification
     "
     |editSpec rowNr colNr newCol oldCol oldRow sensor sglSelRow oldSz
-     keyBrdFwd filter edValue|
+     keyBrdFwd filter edValue edView|
 
     rowNr := self validateSelection:aRowNr.
 
@@ -3191,7 +3234,8 @@
             ] ifFalse:[
                 editView viewBackground:hgLgBgColor
             ].
-            editView add:(editSpec at:1).
+            edView := editSpec at:1.
+            editView add:edView.
             oldSz := editSpec size.
 
             oldSz == 3 ifTrue:[
@@ -3212,7 +3256,8 @@
                 editValue addDependent:self.
             ].
             editView realize.
-            self windowGroup focusView:(editSpec at:1).
+            edView canTab:true.
+            self windowGroup focusView:edView.
 
         ] ifFalse:[
             self invalidateRowAt:sglSelRow colAt:colNr
@@ -3267,5 +3312,5 @@
 !DSVColumnView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.97 2000-01-31 15:32:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.98 2000-02-01 13:53:30 ca Exp $'
 ! !