[Pkg] The Trunk: Morphic-nice.558.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Aug 3 16:23:22 UTC 2011

Nicolas Cellier uploaded a new version of Morphic to project The Trunk:

==================== Summary ====================

Name: Morphic-nice.558
Author: nice
Time: 3 August 2011, 6:22:02.488 pm
UUID: 236ff443-b885-4221-ac18-c426d6bb5424
Ancestors: Morphic-ul.557

ParagraphEditor is an old st-80 class implemented for a polling UI via the use of sensor inst. var..
TextMorphEditor is a glue that enable using a ParagraphEditor in an event driven morphic world.
There was a hack for feeding a sensor fake with morphic events.
This hack was located in TextMorph.
When 100% morphic Cuis-designed TextEditor was introduced in Squeak-trunk, it was made sensor-dependent instead of sensor-less and purely event driven. This should not be so.

This version moves the hack where in belongs to, in TextMorphEditor>>fakeSensorWithEvent:
It also temporarily duplicates it in TextEditor, in the interim before we remove it's sensor inst. var..

NOTE 1: the hack did also previously apply to #mouseUp: #mouseDown: #mouseUp: events.
It does not anymore because I saw no use to it.
If I'm wrong, correct it by sending (self fakeSensorWithEvent: anEvent) in the TextMorphEditor implementation of these messages.

NOTE2: the change does not change the behaviour of MVC projects. Keyboard typing still "works" (cough...)

=============== Diff against Morphic-ul.557 ===============

Item was changed:
  ----- Method: PluggableTextMorph>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
+ 	"A keystroke was hit while the receiver had keyboard focus.  Pass the keystroke on to my textMorph, and and also, if I have an event handler, pass it on to that handler"
- 	"A keystroke was hit while the receiver had keyboard focus.  Pass the keywtroke on to my textMorph, and and also, if I have an event handler, pass it on to that handler"
  	textMorph keyStroke: evt.
  	self eventHandler ifNotNil:
  		[self eventHandler keyStroke: evt fromMorph: self].

Item was added:
+ ----- Method: TextEditor>>keyStroke: (in category 'events') -----
+ keyStroke: anEvent
+ 	"Temporary hack to handle keyboard events thru sensor"
+ 	self sensor: (KeyboardBuffer new startingEvent: anEvent).
+ 	self readKeyboard!

Item was changed:
  ----- Method: TextMorph>>handleInteraction:fromEvent: (in category 'editing') -----
  handleInteraction: interactionBlock fromEvent: evt
  	"Perform the changes in interactionBlock, noting any change in selection
  	and possibly a change in the size of the paragraph (ar 9/22/2001 - added for TextPrintIts)"
- 	"Also couple ParagraphEditor to Morphic keyboard events"
  	| oldEditor oldParagraph oldText |
- 	self editor sensor: (KeyboardBuffer new startingEvent: evt).
  	oldEditor := editor.
  	oldParagraph := paragraph.
  	oldText := oldParagraph text copy.
  	self selectionChanged.  "Note old selection"
  		interactionBlock value.
  	(oldParagraph == paragraph) ifTrue:[
  		"this will not work if the paragraph changed"
  		editor := oldEditor.     "since it may have been changed while in block"
  	self selectionChanged.  "Note new selection"
  	(oldText = paragraph text and: [ oldText runs = paragraph text runs ])
  		ifFalse:[ self updateFromParagraph ].
  	self setCompositionWindow.!

Item was changed:
  ----- Method: TextMorph>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
  	"Handle a keystroke event."
  	self resetBlinkCursor. "don't blink during type-in"
  		codeCompletionAround: [
  			evt keyValue = 13 ifTrue: [ "CR - check for special action"
  				self crAction ifNotNil: [ :action |
  					"Note: Code below assumes that this was some
  					input field reacting on CR. Break the keyboard
  					focus so that the receiver can be safely deleted."
  					evt hand newKeyboardFocus: nil.
  					^action valueWithEnoughArguments: { evt } ] ].
+ 			self handleInteraction: [ editor keyStroke: evt ] fromEvent: evt.
- 			self handleInteraction: [ editor readKeyboard ] fromEvent: evt.
  			"self updateFromParagraph."
  			super keyStroke: evt  "sends to keyStroke event handler, if any" ]
  		textMorph: self
  		keyStroke: evt!

Item was added:
+ ----- Method: TextMorphEditor>>fakeSensorWithEvent: (in category 'typing support') -----
+ fakeSensorWithEvent: anEvent
+ 	"Pass the event to a polling-friendly-sensor-fake so that old st-80 code shall still work"
+ 	self sensor: (KeyboardBuffer new startingEvent: anEvent).!

Item was added:
+ ----- Method: TextMorphEditor>>keyStroke: (in category 'events') -----
+ keyStroke: anEvent
+ 	self fakeSensorWithEvent: anEvent.
+ 	self readKeyboard.
+ 	self storeSelectionInParagraph!

More information about the Packages mailing list