MUHRTH@tubvm.cs.tu-berlin.de (Thomas Muhr) (08/06/90)
The following implements a subclass of ListPane to differentiate between a first and a second click on an item. Useful in complex interactive applications. To file it in without modifications, you should have Max Ott's Category Browser or a copy of the 'methods'-method in Behavior named: methodsInCategory: aCat "**************************** * 1 Aug 1990 15:15:03 * * Project: DoubleClickList * Smalltalk at: #FileInDir put: Disk. (Disk file: 'DblClckL.cls') fileIn; close. Smalltalk removeKey: #FileInDir "! ListPane subclass: #LiListPane instanceVariableNames: ' changeSelectorAt2ndClick lastAction' classVariableNames: '' poolDictionaries: '' ! !LiListPane class methodsInCategory: 'Doc'! classInfo "Autor: Th. Muhr, Datum: 16 Jun 1990 Kommentar: " ^' LiListPanes differentiates between first and second click on a list item. First click activates what was made available via the changeSelector-block. Second click on the already inversed item activates the changeSelectorAt2ndClick-block.If specification of 2nd process via changeAt2ndClick is omitted the pane behaves like a normal ListPane. Example: (this is not a working example, but shows the use within an open-method) fragPane:= (LiListPane new model: self; menu: #fragMenu; name: #fragArray; change: #showTextFragment:; changeAt2ndClick:#showReferences:; font: self listFont; framingRatio: zlfr). '! ! !LiListPane methodsInCategory: 'etc'! changeAt2ndClick: aBlock "Autor: Th. Muhr, Datum: 16 Jun 1990 Kommentar: " changeSelectorAt2ndClick := aBlock! selectAtCursor "Autor: Th. Muhr, Datum: 16 Jun 1990 Kommentar: " self findCurrentLine. self topPane textModified ifTrue: [^self]. currentLine isNil ifTrue: [^self] ifFalse: [ currentLine > list size ifTrue: [^self]]. ((currentLine == selection) and: [(lastAction == #firstSelector) and: [changeSelectorAt2ndClick isNil not]] ) ifTrue:[lastAction:= #secondSelector. model perform: changeSelectorAt2ndClick with: (returnIndex ifTrue: [selection] ifFalse: [list at: selection])] ifFalse: [lastAction:= #firstSelector. self hideSelection. self boldLine: currentLine. selection := currentLine. model perform: changeSelector with: (returnIndex ifTrue: [selection] ifFalse: [list at: selection])]! !