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

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

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

Name: Morphic-mt.1160
Author: mt
Time: 4 June 2016, 4:57:05.250373 pm
UUID: 42f04455-424e-3545-9fe9-7d71a1e77383
Ancestors: Morphic-mt.1159

Moves automatic keyboard focus grabbing from KeyboardEvent into the Morph's key-stroke-handler. More robust when events bubble up again. No accidential focus grab anymore.

=============== Diff against Morphic-mt.1159 ===============

Item was changed:
  ----- Method: KeyboardEvent>>sentTo: (in category 'dispatching') -----
+ sentTo: anObject
+ "Dispatch the receiver into anObject"
+ type == #keystroke ifTrue:[^anObject handleKeystroke: self].
+ type == #keyDown ifTrue:[^anObject handleKeyDown: self].
+ type == #keyUp ifTrue:[^anObject handleKeyUp: self].
+ ^super sentTo: anObject.!
- sentTo: aMorph
- "Dispatch the receiver into the given morph or another one if keyboard focus changes."
-
- | receivingMorph |
- receivingMorph := aMorph.
- aMorph wantsKeyboardFocus ifTrue: [
- receivingMorph := (self hand newKeyboardFocus: aMorph) ifNil: [aMorph]].
-
- type == #keystroke ifTrue:[^receivingMorph handleKeystroke: self].
- type == #keyDown ifTrue:[^receivingMorph handleKeyDown: self].
- type == #keyUp ifTrue:[^receivingMorph handleKeyUp: self].
-
- ^super sentTo: receivingMorph!

Item was changed:
  ----- Method: Morph>>handleKeystroke: (in category 'events-processing') -----
  handleKeystroke: anEvent
+ "System level event handling. Has support for automatically grabbing the keyboard focus considering the keyboard focus delegate. See #newKeyboardFocus:"
- "System level event handling."
 
+ | handler |
+ anEvent wasHandled ifTrue: [^ self].
+ (self handlesKeyboard: anEvent) ifFalse: [^ self].
+
+ handler := self wantsKeyboardFocus
+ ifFalse: [self]
+ ifTrue: [(anEvent hand newKeyboardFocus: self) ifNil: [self]].
+ anEvent handler: handler.
+
- anEvent wasHandled
- ifTrue: [^ self].
- (self handlesKeyboard: anEvent)
- ifFalse: [^ self].
  anEvent wasHandled: true.
+ ^ handler keyStroke: anEvent!
- ^ self keyStroke: anEvent!

Item was changed:
  ----- Method: TextMorph>>handleKeystroke: (in category 'events-processing') -----
  handleKeystroke: anEvent
+ "Overwritten to support tab-among-fields preference."
- "System level event handling."
 
  | pasteUp |
  anEvent wasHandled ifTrue:[^self].
+ (self handlesKeyboard: anEvent) ifFalse: [^ self].
+
+ anEvent keyCharacter = Character tab ifTrue: [
+ "Allow passing through text morph inside pasteups"
+ (self wouldAcceptKeyboardFocusUponTab
+ and: [(pasteUp := self pasteUpMorphHandlingTabAmongFields) notNil])
+ ifTrue: [
+ anEvent wasHandled: true.
+ ^ pasteUp tabHitWithEvent: anEvent]].
+
+ ^ super handleKeystroke: anEvent!
- (self handlesKeyboard: anEvent) ifFalse: [^ self].
- anEvent wasHandled: true.
- anEvent keyCharacter = Character tab ifTrue:
- ["Allow passing through text morph inside pasteups"
- (self wouldAcceptKeyboardFocusUponTab and:
- [(pasteUp := self pasteUpMorphHandlingTabAmongFields) notNil])
- ifTrue:[^ pasteUp tabHitWithEvent: anEvent]].
- self keyStroke: anEvent!

Item was added:
+ ----- Method: TextMorph>>wantsKeyboardFocus (in category 'event handling') -----
+ wantsKeyboardFocus
+
+ ^ true!