[squeak-dev] A small cursor glitch

Stéphane Rollandin lecteur at zogotounga.net
Thu Oct 18 13:16:01 UTC 2018


When a halo in invoked on a morph which is right over a text with focus, 
the cursor keeps its text form even within the halo handles.

I have fixed this for my own usage in the attached code, but I do not 
know if it is the proper way to go, or if this has unwanted side effects 
(I guess it does).

The culprit is in method #dispatchFocusEventAllOver:with: in 
MorphicEventDispatcher


Stef
-------------- next part --------------
'From Squeak5.2 of 13 December 2018 [latest update: #18221] on 18 October 2018 at 3:09:25 pm'!

!MorphicEventDispatcher methodsFor: '*People-spfa-fixes' stamp: 'spfa 10/18/2018 15:08'!
dispatchFocusEventAllOver: evt with: focusMorph
	"Like a full event dispatch BUT adds regular dispatch if the focus morph did nothing with the event. This is useful for letting the focusMorph's siblings handle the events instead. Take halo invocation as an example. See senders of me."
	
	| result hand mouseFocus |
	result := self dispatchFocusEventFully: evt with: focusMorph.
	
	result == #rejected ifTrue: [^ result].
	result wasIgnored ifTrue: [^ result].
	result wasHandled ifTrue: [^ result].
	focusMorph world ifNil: [ ^ result ].

	hand := evt hand.
	mouseFocus := hand mouseFocus.

	[
		"Avoid re-dispatching the event to the focus morph. See Morph >> #rejectsEvent:."
		focusMorph lock.
		
		"Handle side effect for mouse-enter and mouse-leave events."
		self flag: #hacky. "mt: Maybe we find a better way to synthesize enter/leave events in the future."
		hand newMouseFocus: nil.
		hand mouseOverHandler processMouseOver: hand lastEvent.
		
		"Give the morph's world a chance to normally dispatch the event."
		^ focusMorph world ifNotNil: [ : world | world processEvent: evt using: self]
	] ensure: [
		focusMorph unlock.
		"the test below allows halo handles to have a proper normal cursor over them when they themselves appears over a text morph with focus - else the text cursor is restored"
		(focusMorph world notNil and: [focusMorph containsPoint: evt position]) 
			ifFalse: [hand newMouseFocus: mouseFocus]]! !



More information about the Squeak-dev mailing list