DSVColumnView.st
changeset 2813 74cfefd3a0a4
parent 2812 190f880769cb
child 2816 7e36fce15001
equal deleted inserted replaced
2812:190f880769cb 2813:74cfefd3a0a4
  2122 !
  2122 !
  2123 
  2123 
  2124 buttonPress:button x:x y:y
  2124 buttonPress:button x:x y:y
  2125     "a button was pressed - handle selection here"
  2125     "a button was pressed - handle selection here"
  2126 
  2126 
  2127     |rowNr colNr firstRowNr menu sensor clickPoint|
  2127     |rowNr colNr firstRowNr menu sensor clickPoint clickedIntoSelection|
  2128 
  2128 
  2129     clickPoint := x @ y.
  2129     clickPoint := x @ y.
  2130 
  2130 
  2131     buttonMotionAction := buttonReleaseAction := nil.
  2131     buttonMotionAction := buttonReleaseAction := nil.
  2132 
  2132 
  2150         super buttonPress:button x:x y:y.
  2150         super buttonPress:button x:x y:y.
  2151         ^ self
  2151         ^ self
  2152     ].
  2152     ].
  2153 
  2153 
  2154     (self isRowSelectable:rowNr) ifFalse:[^ self ].
  2154     (self isRowSelectable:rowNr) ifFalse:[^ self ].
       
  2155 
       
  2156     clickedIntoSelection := self isInSelection:rowNr.
  2155 
  2157 
  2156     sensor shiftDown ifTrue:[
  2158     sensor shiftDown ifTrue:[
  2157         (multipleSelectOk and:[selectedRowIndex size ~~ 0]) ifTrue:[
  2159         (multipleSelectOk and:[selectedRowIndex size ~~ 0]) ifTrue:[
  2158             self selectRowFrom:(selectedRowIndex min min:rowNr)
  2160             self selectRowFrom:(selectedRowIndex min min:rowNr)
  2159                             to:(selectedRowIndex max max:rowNr).
  2161                             to:(selectedRowIndex max max:rowNr).
  2164     ].
  2166     ].
  2165 
  2167 
  2166     sensor ctrlDown ifTrue:[
  2168     sensor ctrlDown ifTrue:[
  2167         self buttonControlPressAtRowNr:rowNr.
  2169         self buttonControlPressAtRowNr:rowNr.
  2168 "/        ^ self
  2170 "/        ^ self
  2169     ].
  2171     ] ifFalse:[
  2170 
       
  2171     sensor ctrlDown ifFalse:[
       
  2172 "/    self withWaitCursorDo:[
       
  2173         (self isInSelection:rowNr) ifTrue:[
  2172         (self isInSelection:rowNr) ifTrue:[
  2174             buttonReleaseAction := 
  2173             buttonReleaseAction := 
  2175                 [ 
  2174                 [ 
  2176                     self selectRowAt:rowNr colAt:colNr atPoint:clickPoint.
  2175                     self selectRowAt:rowNr colAt:colNr atPoint:clickPoint.
  2177                 ]
  2176                 ]
  2178         ] ifFalse:[
  2177         ] ifFalse:[
  2179             self selectRowAt:rowNr colAt:colNr atPoint:clickPoint.
  2178             self selectRowAt:rowNr colAt:colNr atPoint:clickPoint.
  2180         ]
  2179         ]
  2181     ].
  2180     ].
  2182 
  2181 
       
  2182     clickedIntoSelection ifTrue:[
       
  2183         buttonMotionAction := [:p|
       
  2184             self canDrag ifTrue:[
       
  2185                 (((p x dist:clickPoint x) > (UserPreferences current motionDistanceToStartDrag))     
       
  2186                 or:[p x < -5 or:[p x > (width+5)]]) ifTrue:[     
       
  2187                     buttonReleaseAction := buttonMotionAction := nil.
       
  2188                     self startDragAt:p
       
  2189                 ]
       
  2190             ].
       
  2191         ].
       
  2192         ^ self.
       
  2193     ].
       
  2194 
  2183     buttonMotionAction := [:p|
  2195     buttonMotionAction := [:p|
  2184         |r2|
  2196         |r2|
  2185 
  2197 
  2186 "/ cg: disabled: I dont want to loose the selection when starting
  2198         (self bounds containsPoint:p) ifTrue:[
  2187 "/     a drag.
  2199             multipleSelectOk ifTrue:[
  2188 "/        (self bounds containsPoint:p) ifTrue:[
  2200                 r2 := self yVisibleToRowNr:(p y).
  2189 "/            multipleSelectOk ifTrue:[
  2201                 r2 notNil ifTrue:[
  2190 "/                r2 := self yVisibleToRowNr:(p y).
       
  2191 "/                r2 notNil ifTrue:[
       
  2192 "/                    r2 ~~ self lastIndexSelected ifTrue:[
  2202 "/                    r2 ~~ self lastIndexSelected ifTrue:[
  2193 "/                        self selectRowFrom:firstRowNr to:r2.
  2203                         self selectRowFrom:firstRowNr to:r2.
  2194 "/                        clickPoint := p.
  2204                         clickPoint := p.
  2195 "/                    ].
  2205 "/                    ].
  2196 "/                ].
  2206                 ].
  2197 "/            ].
  2207             ].
  2198 "/        ].
  2208         ].
  2199 
  2209 
  2200         self canDrag ifTrue:[
  2210         self canDrag ifTrue:[
  2201             (((p x dist:clickPoint x) > (UserPreferences current motionDistanceToStartDrag))     
  2211             (((p x dist:clickPoint x) > (UserPreferences current motionDistanceToStartDrag))     
  2202             or:[p x < -5 or:[p x > (width+5)]]) ifTrue:[     
  2212             or:[p x < -5 or:[p x > (width+5)]]) ifTrue:[     
  2203                 buttonReleaseAction := buttonMotionAction := nil.
  2213                 buttonReleaseAction := buttonMotionAction := nil.
  2204                 self startDragAt:p
  2214                 self startDragAt:p
  2205             ]
  2215             ]
  2206         ].
  2216         ].
  2207     ].
  2217     ].
  2208 
       
  2209 "/    (multipleSelectOk and:[selectedColIndex == 0 and:[selectedRowIndex size == 1]]) ifTrue:[
       
  2210 "/        buttonMotionAction := [:p| 
       
  2211 "/            |r|
       
  2212 "/
       
  2213 "/            (self bounds contains:p) ifFalse:[
       
  2214 "/                buttonReleaseAction := buttonMotionAction := nil.
       
  2215 "/                self startDragAt:p.
       
  2216 "/                ^ self.
       
  2217 "/            ].
       
  2218 "/            r := self yVisibleToRowNr:(p y).
       
  2219 "/            r notNil ifTrue:[ self selectRowFrom:rowNr to:r ].
       
  2220 "/        ]
       
  2221 "/    ].
       
  2222 !
  2218 !
  2223 
  2219 
  2224 buttonRelease:button x:x y:y
  2220 buttonRelease:button x:x y:y
  2225 
  2221 
  2226     buttonMotionAction := nil.
  2222     buttonMotionAction := nil.
  4056 ! !
  4052 ! !
  4057 
  4053 
  4058 !DSVColumnView class methodsFor:'documentation'!
  4054 !DSVColumnView class methodsFor:'documentation'!
  4059 
  4055 
  4060 version
  4056 version
  4061     ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.201 2005-05-04 07:39:01 cg Exp $'
  4057     ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.202 2005-05-04 14:12:12 cg Exp $'
  4062 ! !
  4058 ! !