[FIX] 1483ListItemSelect-JLM
Jason McVay
jmcvay at bigfoot.com
Tue Sep 28 06:00:25 UTC 1999
there was one tiny bug that i had to squash...
'From Squeak 2.5 of August 6, 1999 on 28 September 1999 at 12:58:51 am'!
!PluggableListMorph methodsFor: 'model access' stamp: 'JLM 9/26/1999 23:34'!
keyStroke: event
"Process potential command keys"
| args aChar aLowercaseChar oldSelection aSpecialKey nextSelection
nextSelectionList nextSelectionText max howManyItemsShowing |
aChar _ event keyCharacter.
(event anyModifierKeyPressed or: [self listHandlesBasicKeys not])
ifTrue:
[keystrokeActionSelector == nil ifTrue: [^ nil].
(args _ keystrokeActionSelector numArgs) = 1 ifTrue: [^ model perform:
keystrokeActionSelector with: aChar].
args = 2 ifTrue: [^ model
perform: keystrokeActionSelector
with: aChar
with: self].
^ self error: 'The keystrokeActionSelector must be a 1- or 2-keyword
symbol'].
oldSelection _ self selectionIndex.
nextSelection _ oldSelection.
aSpecialKey _ aChar asciiValue.
max _ self maximumSelection.
aSpecialKey < 32
ifTrue:
[" one of a number of special keys"
aSpecialKey == 31
ifTrue:
[" down arrow"
nextSelection _ oldSelection + 1.
nextSelection > max ifTrue: [nextSelection _ 1]].
aSpecialKey == 30
ifTrue:
[" up arrow"
nextSelection _ oldSelection - 1.
nextSelection < 1 ifTrue: [nextSelection _ max]].
aSpecialKey == 1 ifTrue: [" home"
nextSelection _ 1].
aSpecialKey == 4 ifTrue: [" end"
nextSelection _ max].
howManyItemsShowing _ self numSelectionsInView.
aSpecialKey == 11 ifTrue: [" page up"
nextSelection _ 1 max: oldSelection - howManyItemsShowing].
aSpecialKey == 12 ifTrue: [" page down"
nextSelection _ oldSelection + howManyItemsShowing min: max].
^ self changeModelSelection: nextSelection].
aLowercaseChar _ aChar asLowercase.
nextSelectionList _ list copyFrom: oldSelection + 1 to: max.
nextSelectionList addAll: (list copyFrom: 1 to: oldSelection).
" make sure to get rid of blanks due to the hierarchal nature of some of
the collection entries"
nextSelectionText _ nextSelectionList detect: [:a | (a asString
withBlanksTrimmed at: 1) asLowercase == aLowercaseChar]
ifNone: [nextSelectionText _ nil].
nextSelectionText ~~ nil
ifTrue:
[nextSelection _ list findFirst: [:a | a == nextSelectionText].
^ self changeModelSelection: nextSelection]
ifFalse: [self flash]! !
More information about the Squeak-dev
mailing list
|