Obscuring the cursor while you type (revised)
Bob Arning
arning at charm.net
Sat May 8 21:01:52 UTC 1999
The code I offered yesterday for obscuring the cursor while typing had the unfortunate effect of sometimes failing to restore the cursor - quite annoying, really. The code below does a better job.
Cheers,
Bob
==================filein below===============
'From Squeak 2.4b of April 23, 1999 on 8 May 1999 at 12:23:58 am'!
Cursor subclass: #ObscuredCursor
instanceVariableNames: 'previousCursor previousCursorPoint '
classVariableNames: ''
poolDictionaries: ''
category: 'Graphics-Display Objects'!
!Object methodsFor: 'testing' stamp: 'RAA 5/7/1999 12:48'!
wantsObscuredCursor
^ false! !
!Cursor methodsFor: 'displaying' stamp: 'RAA 5/8/1999 00:09'!
obscureCursorAt: aPoint
ObscuredCursor new
setPreviousCursor: self
previousCursorPoint: aPoint! !
!Cursor methodsFor: 'displaying' stamp: 'RAA 5/8/1999 00:12'!
unobscureCursorAt: aPoint
"we are not obscured, so do nothing"
! !
!HandMorph methodsFor: 'event handling' stamp: 'RAA 5/8/1999 00:18'!
handleEvent: evt
eventSubscribers do: [:m | m handleEvent: evt].
"--"
(evt anyButtonPressed and:
[evt controlKeyPressed and:
[lastEvent anyButtonPressed not]]) ifTrue:
[eventTransform _ MorphicTransform identity.
lastEvent _ evt.
^ self invokeMetaMenu: evt].
evt blueButtonPressed ifTrue:
[lastEvent blueButtonPressed
ifTrue: [^ self specialDrag: evt]
ifFalse: [eventTransform _ MorphicTransform identity.
lastEvent _ evt.
^ self specialGesture: evt]].
"--"
lastEvent _ evt.
self position ~= evt cursorPoint
ifTrue: [self position: evt cursorPoint].
evt isMouse ifTrue: [
Sensor currentCursor unobscureCursorAt: evt cursorPoint.
evt isMouseMove ifTrue: [^ self handleMouseMove: evt].
evt isMouseDown ifTrue: [ ^ self handleMouseDown: evt].
evt isMouseUp ifTrue: [^ self handleMouseUp: evt]].
evt isKeystroke ifTrue: [
keyboardFocus wantsObscuredCursor ifTrue: [
Sensor currentCursor obscureCursorAt: evt cursorPoint.
].
keyboardFocus ifNotNil: [keyboardFocus keyStroke: evt].
^ self].
! !
!ObscuredCursor methodsFor: 'as yet unclassified' stamp: 'RAA 5/8/1999 00:23'!
obscureCursorAt: aPoint
"we are already obscured, so do nothing"! !
!ObscuredCursor methodsFor: 'as yet unclassified' stamp: 'RAA 5/8/1999 00:08'!
setPreviousCursor: aCursor previousCursorPoint: aPoint
previousCursor _ aCursor.
previousCursorPoint _ aPoint.
self show.! !
!ObscuredCursor methodsFor: 'as yet unclassified' stamp: 'RAA 5/8/1999 00:17'!
unobscureCursorAt: aPoint
aPoint = previousCursorPoint ifFalse: [previousCursor show]
! !
!TextMorphForEditView methodsFor: 'as yet unclassified' stamp: 'RAA 5/7/1999 12:53'!
wantsObscuredCursor
^ true! !
More information about the Squeak-dev
mailing list
|