[ENH] Keyboard navigation in hierarchical lists ([er][et][approved])

Daniel Vainsencher danielv at netvision.net.il
Wed Oct 15 01:33:13 UTC 2003


This makes a big difference for various things, including the new
hierarchial SM2 Package Loader...

Daniel

Andreas Raab <andreas.raab at gmx.de> wrote:
> This is a multi-part message in MIME format.
> 
> --Boundary_(ID_OTKnIWZr2ZIULpDGYD2rQQ)
> Content-type: text/plain; charset=us-ascii
> Content-transfer-encoding: 7BIT
> 
> "Change Set:		HierarchyNavigation-ar
> Date:			14 October 2003
> Author:			Andreas Raab
> 
> Adds default keyboard navigation for hierarchical lists. If no
> keystrokeSelector is set, the default keyboard navigation is used. If a
> keystrokeSelector is set, it is the models responsibility to invoke the
> lists #arrowKey: method if keyboard navigation is desired.
> 
> The effect is (for example) immediately noticable in the file list and the
> object explorer"
> 
> --Boundary_(ID_OTKnIWZr2ZIULpDGYD2rQQ)
> Content-type: application/octet-stream; name=HierarchyNavigation-ar.3.cs
> Content-transfer-encoding: quoted-printable
> Content-disposition: attachment; filename=HierarchyNavigation-ar.3.cs
> 
> 'From Squeak3.6 of ''6 October 2003'' [latest update: #5424] on 14 =
> October 2003 at 11:53:20 pm'!=0D"Change Set:		=
> HierarchyNavigation-ar=0DDate:			14 October 2003=0DAuthor:			Andreas =
> Raab=0D=0DAdds default keyboard navigation for hierarchical lists. If no =
> keystrokeSelector is set, the default keyboard navigation is used. If a =
> keystrokeSelector is set, it is the models responsibility to invoke the =
> lists #arrowKey: method if keyboard navigation is desired.=0D=0DThe =
> effect is (for example) immediately noticable in the file list and the =
> object explorer"!=0D=0D=0D!SimpleHierarchicalListMorph methodsFor: =
> 'event handling' stamp: 'ar 10/14/2003 23:40'!=0DkeyStroke: event =0D	=
> "Process potential command keys"=0D=0D	| args aCharacter |=0D	(self =
> scrollByKeyboard: event) ifTrue: [^self].=0D	aCharacter :=3D event =
> keyCharacter.=0D	keystrokeActionSelector isNil ifTrue: [^self arrowKey: =
> aCharacter].=0D	(args :=3D keystrokeActionSelector numArgs) =3D 1 =0D		=
> ifTrue: [^model perform: keystrokeActionSelector with: aCharacter].=0D	=
> args =3D 2 =0D		ifTrue: =0D			[^model =0D				perform: =
> keystrokeActionSelector=0D				with: aCharacter=0D				with: self].=0D	=
> ^self =0D		error: 'The keystrokeActionSelector must be a 1- or 2-keyword =
> symbol'! !=0D=0D!SimpleHierarchicalListMorph methodsFor: 'selection' =
> stamp: 'ar 10/14/2003 23:39'!=0DselectionIndex: idx=0D	"Called =
> internally to select the index-th item."=0D	| theMorph range index |=0D	=
> idx ifNil: [^ self].=0D	index :=3D idx min: scroller submorphs size max: =
> 0.=0D	(theMorph _ index =3D 0 ifTrue: [nil] ifFalse: [scroller submorphs =
> at: index])=0D		ifNotNil:=0D		[((theMorph bounds top - scroller offset =
> y) >=3D 0=0D			and: [(theMorph bounds bottom - scroller offset y) <=3D =
> bounds height]) ifFalse:=0D			["Scroll into view -- should be =
> elsewhere"=0D			range _ self totalScrollRange.=0D			scrollBar value: =
> (range > 0=0D				ifTrue: [((index-1 * theMorph height) / self =
> totalScrollRange)=0D									truncateTo: scrollBar scrollDelta]=0D				=
> ifFalse: [0]).=0D			scroller offset: -3 @ (range * scrollBar =
> value)]].=0D	self selectedMorph: theMorph! =
> !=0D=0D!SimpleHierarchicalListMorph methodsFor: 'keyboard navigation' =
> stamp: 'ar 10/14/2003 23:38'!=0DarrowKey: aChar=0D	"Handle a keyboard =
> navigation character. Answer true if handled, false if not."=0D	| =
> keyEvent |=0D	keyEvent :=3D aChar asciiValue.=0D     keyEvent =3D=3D 31 =
> ifTrue:["down"=0D		self setSelectionIndex: self getSelectionIndex+1.=0D		=
> ^true].=0D     keyEvent =3D=3D 30 ifTrue:["up"=0D		self =
> setSelectionIndex: (self getSelectionIndex-1 max: 1).=0D		^true].=0D     =
> keyEvent =3D=3D 1  ifTrue: ["home"=0D		self setSelectionIndex: 1.=0D		=
> ^true].=0D     keyEvent =3D=3D 4  ifTrue: ["end"=0D		self =
> setSelectionIndex: scroller submorphs size.=0D		^true].=0D      keyEvent =
> =3D=3D 11 ifTrue: ["page up"=0D		self setSelectionIndex: (self =
> getSelectionIndex - self numSelectionsInView max: 1).=0D		^true].=0D     =
> keyEvent =3D=3D 12  ifTrue: ["page down"=0D		self setSelectionIndex: =
> self getSelectionIndex + self numSelectionsInView.=0D		^true].=0D	=
> keyEvent =3D=3D 29 ifTrue:["right"=0D		selectedMorph ifNotNil:[=0D			=
> (selectedMorph canExpand and:[selectedMorph isExpanded not])=0D				=
> ifTrue:[self toggleExpandedState: selectedMorph]=0D				ifFalse:[self =
> setSelectionIndex: self getSelectionIndex+1].=0D		].=0D		^true].=0D	=
> keyEvent =3D=3D 28 ifTrue:["left"=0D		selectedMorph ifNotNil:[=0D			=
> (selectedMorph isExpanded)=0D				ifTrue:[self toggleExpandedState: =
> selectedMorph]=0D				ifFalse:[self setSelectionIndex: (self =
> getSelectionIndex-1 max: 1)].=0D		].=0D		^true].=0D	^false! =
> !=0D=0D!SimpleHierarchicalListMorph methodsFor: 'keyboard navigation' =
> stamp: 'ar 10/14/2003 23:38'!=0DgetSelectionIndex=0D	^scroller submorphs =
> indexOf: selectedMorph! !=0D=0D!SimpleHierarchicalListMorph methodsFor: =
> 'keyboard navigation' stamp: 'ar 10/14/2003 23:39'!=0DsetSelectionIndex: =
> idx=0D	"Called internally to select the index-th item."=0D	| theMorph =
> index |=0D	idx ifNil: [^ self].=0D	index :=3D idx min: scroller =
> submorphs size max: 0.=0D	theMorph _ index =3D 0 ifTrue: [nil] ifFalse: =
> [scroller submorphs at: index].=0D	self setSelectedMorph: theMorph.! =
> !=0D=0D!SimpleHierarchicalListMorph methodsFor: 'keyboard navigation' =
> stamp: 'ar 10/14/2003 23:39'!=0DtoggleExpandedState: aMorph=0D	aMorph =
> toggleExpandedState.=0D	self adjustSubmorphPositions.=0D! !=0D=0D=
> 
> --Boundary_(ID_OTKnIWZr2ZIULpDGYD2rQQ)
> MIME-version: 1.0
> Content-type: text/plain; charset=us-ascii
> Content-transfer-encoding: 7BIT
> 
> 
> 
> --Boundary_(ID_OTKnIWZr2ZIULpDGYD2rQQ)--



More information about the Squeak-dev mailing list