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

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

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

Name: Morphic-mt.851
Author: mt
Time: 10 April 2015, 2:57:59.334 pm
UUID: 034c3519-a911-2e43-a318-d8731bd5ebc4
Ancestors: Morphic-mt.850

Keyboard-focus handling extended. Morphs may no #wantsKeyboardFocus so that they can take advantage of #keyboardFocusChange: in a transparent fashion.

Until now, they to explicitely acquire the keyboard focus, which they sometimes forgot. Thus, #keyboardFocusChange: did not work as expected.

All scroll panes want the keyboard focus. This includes pluggable text morphs and pluggable lists and pluggable trees.

=============== Diff against Morphic-mt.850 ===============

Item was changed:
  ----- Method: HandMorph>>newKeyboardFocus: (in category 'focus handling') -----
  newKeyboardFocus: aMorphOrNil
  "Make the given morph the new keyboard focus, canceling the previous keyboard focus if any. If the argument is nil, the current keyboard focus is cancelled."
+
+ | oldFocus newFocus |
- | oldFocus |
  oldFocus := self keyboardFocus.
+ newFocus := aMorphOrNil ifNotNil: [:m | m keyboardFocusDelegate].
+
+ self keyboardFocus: newFocus.
+
+ oldFocus == newFocus ifFalse: [
+ oldFocus ifNotNil: [:m | m keyboardFocusChange: false].
+ newFocus ifNotNil: [:m | m keyboardFocusChange: true]].
+
+ newFocus ifNotNil: [:m |
+ self compositionWindowManager keyboardFocusForAMorph: m].
+
+ ^ newFocus
- self keyboardFocus: aMorphOrNil.
- oldFocus ifNotNil: [oldFocus == aMorphOrNil ifFalse: [oldFocus keyboardFocusChange: false]].
- aMorphOrNil ifNotNil: [aMorphOrNil keyboardFocusChange: true. self compositionWindowManager keyboardFocusForAMorph: aMorphOrNil].
  !

Item was changed:
  ----- Method: KeyboardEvent>>sentTo: (in category 'dispatching') -----
+ 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!
- 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.!

Item was added:
+ ----- Method: Morph>>keyboardFocusDelegate (in category 'event handling') -----
+ keyboardFocusDelegate
+ "If this morph ever tries to acquire the keyboard focus, this can be delegate to, for example, a submorph."
+
+ ^ self!

Item was added:
+ ----- Method: Morph>>wantsKeyboardFocus (in category 'event handling') -----
+ wantsKeyboardFocus
+ "Whether this morph should get the current keyboard focus when handling a keyboard event to speed up further event processing."
+
+ ^ false!

Item was removed:
- ----- Method: PluggableListMorph>>handlesKeyboard: (in category 'event handling') -----
- handlesKeyboard: evt
- ^true!

Item was changed:
  ----- Method: PluggableListMorph>>keyStroke: (in category 'event handling') -----
  keyStroke: event
  "Process keys
  The model is allowed to preview all keystrokes. If it's not interested:
  specialKeys are things like up, down, etc. ALWAYS HANDLED
  modifierKeys are regular characters either 1) accompanied with ctrl,
  cmd or 2) any character if the list doesn't want to handle basic
  keys (handlesBasicKeys returns false)
  basicKeys are any characters"
+
  | aChar aSpecialKey |
+ (self previewKeystroke: event)
+ ifTrue: [^ self].
+ (self scrollByKeyboard: event)
+ ifTrue: [^ self].
+
- (self previewKeystroke: event) ifTrue: [ ^ self ].
- (self scrollByKeyboard: event) ifTrue: [^self].
  aChar := event keyCharacter.
+
+ (aSpecialKey := aChar asciiValue) < 32
+ ifTrue: [^ self specialKeyPressed: aSpecialKey].
+
- aSpecialKey := aChar asciiValue.
- aSpecialKey < 32 ifTrue: [^ self specialKeyPressed: aSpecialKey].
  (event anyModifierKeyPressed or: [self handlesBasicKeys not])
  ifTrue: [^ self modifierKeyPressed: aChar].
+
  ^ self basicKeyPressed: aChar!

Item was removed:
- ----- Method: PluggableTextMorph>>handlesKeyboard: (in category 'event handling') -----
- handlesKeyboard: evt
- ^true!

Item was added:
+ ----- Method: PluggableTextMorph>>keyboardFocusDelegate (in category 'event handling') -----
+ keyboardFocusDelegate
+
+ ^ textMorph ifNil: [self]!

Item was added:
+ ----- Method: ScrollPane>>handlesKeyboard: (in category 'event handling') -----
+ handlesKeyboard: evt
+ ^ true!

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

Item was removed:
- ----- Method: SimpleHierarchicalListMorph>>handlesKeyboard: (in category 'event handling') -----
- handlesKeyboard: evt
- ^true!