The Trunk: Morphic-mt.1166.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-mt.1166.mcz

commits-2
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1166.mcz

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

Name: Morphic-mt.1166
Author: mt
Time: 5 June 2016, 9:31:27.57571 am
UUID: b8c7c456-a88e-3143-8c24-09fae212f9b9
Ancestors: Morphic-mt.1165

Fixes the bug where the text cursor was not blinking in text morphs after a dialog box appeared and was closed again.

For blinking text cursors, make the ifNil-check for paragraphs useful again. Using the accessor #paragraph will always create a paragraph. We have to directly check the instance variable to make this improvement effective.

Note that regular TextMorphs do not keep track of their editors and paragraphs after they lose keyboard focus. I am not sure why but this seems to be a performance optimization.

=============== Diff against Morphic-mt.1165 ===============

Item was changed:
  ----- Method: TextMorph>>keyboardFocusChange: (in category 'event handling') -----
+ keyboardFocusChange: weHaveFocus
+
+ paragraph ifNotNil: [:para | para focused: weHaveFocus].
+
+ weHaveFocus
+ ifTrue: [ "A hand is wanting to send us characters..."
- keyboardFocusChange: aBoolean
- | w |
- paragraph isNil ifFalse:[paragraph focused: aBoolean].
- aBoolean ifTrue:["A hand is wanting to send us characters..."
  self hasFocus ifFalse: [self editor "Forces install"].
+ Editor blinkingCursor
+ ifTrue: [self startBlinking]
+ ifFalse: [self resetBlinkCursor "ensure caret visible"]]
+ ifFalse: [ "A hand has clicked elsewhere..."
+ self world ifNotNil: [:w |
+ self flag: #suspicious. "mt: Why should this be called with 'false' if a hand holds on the focus? Do hands not talk to each other before sending this call? They should..."
+ w handsDo: [:h | h keyboardFocus == self ifTrue: [^self]].
+ "Release control unless some hand is still holding on"
+ self releaseEditor].
+ self stopBlinking].
- Editor blinkingCursor ifTrue: [ self startBlinking ].
- ] ifFalse:["A hand has clicked elsewhere..."
- (w := self world) ifNotNil:[
- w handsDo: [:h | h keyboardFocus == self ifTrue: [^self]].
- "Release control unless some hand is still holding on"
- self releaseEditor].
- self stopBlinking.
- ].
  !

Item was changed:
  ----- Method: TextMorph>>onBlinkCursor (in category 'blinking') -----
  onBlinkCursor
+
- "Blink the cursor"
  | para |
+ para := paragraph ifNil: [^nil].
+ Time millisecondClockValue < self blinkStart
+ ifTrue: [para showCaret: para focused]
+ ifFalse: [para showCaret: para showCaret not].
- para := self paragraph ifNil:[^nil].
- Time millisecondClockValue < self blinkStart ifTrue:[
- "don't blink yet"
- ^para showCaret: para focused.
- ].
- para showCaret: para showCaret not.
  para caretRect ifNotNil: [ :r | self invalidRect: r].!

Item was changed:
  ----- Method: TextMorph>>resetBlinkCursor (in category 'blinking') -----
  resetBlinkCursor
  "Reset the blinking cursor"
  | para |
  self blinkStart: Time millisecondClockValue + 500.
+ para := paragraph ifNil: [^self].
- para := self paragraph ifNil:[^self].
  para showCaret = para focused ifFalse:[
  para caretRect ifNotNil: [ :r | self invalidRect: r].
  para showCaret: para focused.
  ].
  !

Item was changed:
  ----- Method: TextMorph>>stopBlinking (in category 'blinking') -----
  stopBlinking
  self stopSteppingSelector: #onBlinkCursor.
+ self resetBlinkCursor. "Ensure caret visible."!
- !

Item was changed:
  ----- Method: TextMorphForEditView>>keyboardFocusChange: (in category 'event handling') -----
+ keyboardFocusChange: weHaveFocus
+ "Overwritten because we do not want to release the editor if we do not have the focus. Editors and their paragraphs store the text selection, which we want to reuse after getting keyboard focus again. This supports keyboard navigation."
+
+ paragraph ifNotNil: [:para | para focused: weHaveFocus].
+
+ weHaveFocus
+ ifFalse: [self stopBlinking]
- keyboardFocusChange: aBoolean
- "rr 3/21/2004 22:55 : removed the #ifFalse: branch,
- which was responsible of the deselection of text when the
- paragraph lost focus. This way selection works in a more standard
- way, and this permits the menu keyboard control to be really effective"
- paragraph isNil ifFalse:[paragraph focused: aBoolean].
- aBoolean
  ifTrue: [
+ self hasFocus
+ ifFalse: [self editor "forces install"].
+ Editor blinkingCursor
+ ifTrue: [self startBlinking]
+ ifFalse: [self resetBlinkCursor "ensure caret visible"]].
+
- "A hand is wanting to send us characters..."
- self hasFocus ifFalse: [self editor "Forces install"].
- Editor blinkingCursor ifTrue: [self startBlinking]]
- ifFalse:[
- self stopBlinking].
  self changed.
 
  "Tell my edit-view about this because I am his delegate."
+ self editView keyboardFocusChange: weHaveFocus.
- self editView keyboardFocusChange: aBoolean.
  !

Item was changed:
  ----- Method: UserDialogBoxMorph>>runModalIn:forHand:at: (in category 'running') -----
  runModalIn: aWorld forHand: aHand at: aPointOrNil
  "Ensure that we have a reasonable minimum size"
  | oldFocus pos offset |
  (ProvideAnswerNotification signal: self label asString) ifNotNil:[:answer| ^answer].
  self openInWorld: aWorld.
  pos := aPointOrNil ifNil: [
  "If called after a longer UI operation, be sure to use the current mouse cursor. Hand position is not up-to-date. Do one world cycle does not help if there are currently no mouse events. So, we *have to be* this extreme."
  Sensor cursorPoint].
  offset := aPointOrNil
  ifNil: [selectedButton fullBounds origin - (selectedButton fullBounds extent // 2 * (-1@1))]
  ifNotNil: [self fullBounds extent // 2].
  self setConstrainedPosition: pos - offset hangOut: false.
  oldFocus := aHand keyboardFocus.
  aHand newMouseFocus: self.
  aHand newKeyboardFocus: self.
  savedLabel := selectedButton label.
  [self isInWorld] whileTrue:[aWorld doOneSubCycle].
+ oldFocus ifNotNil:[aHand newKeyboardFocus: oldFocus].
- oldFocus ifNotNil:[aHand keyboardFocus: oldFocus].
  ^value!