The Trunk: Morphic-bf.1122.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-bf.1122.mcz

commits-2
Bert Freudenberg uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-bf.1122.mcz

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

Name: Morphic-bf.1122
Author: bf
Time: 20 April 2016, 6:09:34.906493 pm
UUID: a3dac7ab-cefe-4c77-9a8f-2d45f7f0dd9e
Ancestors: Morphic-tfel.1121

Prevent DNU when keystroke event causes text editor to get closed (owner is nil)

=============== Diff against Morphic-tfel.1121 ===============

Item was changed:
  ----- Method: StringMorphEditor>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
  "This is hugely inefficient, but it seems to work, and it's unlikely it will ever need
  to be any more efficient -- it's only intended to edit single-line strings."
 
  | char priorEditor newSel |
  (((char := evt keyCharacter) = Character enter) or: [(char = Character cr)
  or: [char = $s and: [evt commandKeyPressed]]])
  ifTrue: [owner doneWithEdits; acceptContents.
  self flag: #arNote. "Probably unnecessary"
  evt hand releaseKeyboardFocus.
  ^ self delete].
 
  (char = $l and: [evt commandKeyPressed]) ifTrue:   "cancel"
  [owner cancelEdits.
  evt hand releaseKeyboardFocus.
  ^ self delete].
 
  super keyStroke: evt.
+
+ owner ifNil: [^self].
  owner interimContents: self contents asString.
  newSel := self editor selectionInterval.
 
  priorEditor := self editor.  "Save editor state"
  self releaseParagraph.  "Release paragraph so it will grow with selection."
  self paragraph.      "Re-instantiate to set new bounds"
  self installEditorToReplace: priorEditor.  "restore editor state"
  self editor selectFrom: newSel first to: newSel last.
  !