[HOWTO] get mouseEnter and mouseLeave when btn down

Ned Konz ned at bike-nomad.com
Thu Apr 12 21:49:26 UTC 2001


On Thursday 12 April 2001 13:58, montgomery f. tidwell wrote:
> Howdy,
>
> what i want is for the morph to change colors when clicked. if
> when i click, i keep the btn down, i want it to revert to its
> original color if the mouse leaves its area, and change again
> (to the new color) of the mouse is brought back into the morph.
>
> i don't see how mouseStillDown will help, in this case.

Actually, you don't even need it. I don't know about what baggage you're 
referring to with mouse focus. Doesn't this do what you want?

'From Squeak3.1alpha [latest update: #''Squeak3.1alpha'' of 7 March 2001 
update 3910] on 12 April 2001 at 2:47:29 pm'!
RectangleMorph subclass: #TestRectangleMorph
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'NK-Test'!

!TestRectangleMorph methodsFor: 'event handling' stamp: 'nk 4/12/2001 14:30'!
handlesMouseDown: evt
	^true! !

!TestRectangleMorph methodsFor: 'event handling' stamp: 'nk 4/12/2001 14:41'!
mouseDown: evt
	self color: Color orange.
	evt hand newMouseFocus: self.! !

!TestRectangleMorph methodsFor: 'event handling' stamp: 'nk 4/12/2001 14:46'!
mouseMove: evt
	(self containsPoint: evt position)
		ifTrue: [ self color: Color orange ]
		ifFalse: [ self color: Color gray ]! !

!TestRectangleMorph methodsFor: 'event handling' stamp: 'nk 4/12/2001 14:41'!
mouseUp: evt
	evt hand releaseMouseFocus: self.! !

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com





More information about the Squeak-dev mailing list