How does double clicking work in Squeak?

Bob Arning arning at charm.net
Thu Sep 23 16:54:32 UTC 1999


On Thu, 23 Sep 1999 11:26:51 -0400 "Norton, Chris" <chrisn at Kronos.com> wrote:
>Before I reply to this note, please allow me to ask again if anyone knows
>anything about double clicking in Squeak.  I'm still interested in working
>with this functionality and I haven't made any progress on it yet...  A code
>snippet would be GREATLY appreciated!  Thanks!!

Chris,

Here is a snippet that makes the Inspector double-click sensitive.

Cheers,
Bob

=========snippet===========
'From Squeak 2.5 of August 6, 1999 on 23 September 1999 at 12:51:25 pm'!
PluggableListMorph subclass: #PluggableListMorphWithDC
	instanceVariableNames: 'lastClickTime doubleClickSelector '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Morphic-Windows'!

!Inspector class methodsFor: 'instance creation' stamp: 'RAA 9/23/1999 12:34'!
openAsMorphOn: anObject withLabel: aLabel
	"(Inspector openAsMorphOn: SystemOrganization) openInMVC"
	| window inspector |
	inspector _ self inspect: anObject.
	window _ (SystemWindow labelled: aLabel)
				model: inspector.

	window addMorph: ((PluggableListMorphWithDC on: inspector list: #fieldList
				selected: #selectionIndex changeSelected: #toggleIndex:
				menu: ((inspector isMemberOf: DictionaryInspector)
						ifTrue: [#dictionaryMenu:]
						ifFalse: [#fieldListMenu:])
				keystroke: #inspectorKey:from:)
				doubleClickSelector: #inspectSelection)
		frame: (0 at 0 corner: 0.3 at 0.7).
	window addMorph: (PluggableTextMorph on: inspector text: #contents accept: #accept:
				readSelection: #contentsSelection menu: #codePaneMenu:shifted:)
		frame: (0.3 at 0 corner: 1 at 0.7).
	window addMorph: ((PluggableTextMorph on: inspector text: #trash accept: #trash:
				readSelection: #contentsSelection menu: #codePaneMenu:shifted:)
					askBeforeDiscardingEdits: false)
		frame: (0 at 0.7 corner: 1 at 1).

	window position: 16 at 0.  "Room for scroll bar."
	^ window! !


!PluggableListMorphWithDC methodsFor: 'as yet unclassified' stamp: 'RAA 9/23/1999 12:30'!
doubleClickSelector: aSymbol

	doubleClickSelector _ aSymbol! !

!PluggableListMorphWithDC methodsFor: 'as yet unclassified' stamp: 'RAA 9/23/1999 12:49'!
mouseDown: event onItem: aMorph

	| now delta |

	event yellowButtonPressed ifTrue: [^ self yellowButtonActivity: event shiftPressed].
	now _ Time millisecondClockValue.
	delta _ ((lastClickTime ifNil: [0]) - now) abs.
	lastClickTime _ now.
	(aMorph == selectedMorph and: [doubleClickSelector notNil and: [delta < 1000]]) ifFalse: [
		aMorph == selectedMorph ifTrue: [^self].
		model okToChange ifFalse: [^ self].  "No change if model is locked"
		^self setSelectedMorph: aMorph.
	].
	^model perform: doubleClickSelector

! !





More information about the Squeak-dev mailing list