[squeak-dev] The Trunk: Morphic-mt.1792.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Nov 19 17:13:00 UTC 2021

Marcel Taeumel uploaded a new version of Morphic to project The Trunk:

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

Name: Morphic-mt.1792
Author: mt
Time: 19 November 2021, 6:12:54.045971 pm
UUID: f8bfb597-a32a-074c-a660-b9e3d8f8dfb3
Ancestors: Morphic-mt.1791

Adds support for a default focus in windows when opened. The focus can be a #knownName, a morph, or a block. This improves keyboard navigation a little bit.

See http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-October/216745.html

Adds and uses breadth-first search for submorph lookup because it matches the natural way widgets are organized in a window. The existing depth-first in #allMorphsDo: might take surprising paths.

=============== Diff against Morphic-mt.1791 ===============

Item was added:
+ ----- Method: Morph>>allMorphsBreadthFirstDo: (in category 'submorphs - enumerating') -----
+ allMorphsBreadthFirstDo: aBlock 
+ 	| remaining |
+ 	remaining := OrderedCollection with: self.
+ 	[remaining notEmpty] whileTrue: [
+ 		| next |
+ 		next := remaining removeFirst.
+ 		aBlock value: next.
+ 		remaining addAll: next submorphs].!

Item was added:
+ ----- Method: Morph>>allMorphsDepthFirstDo: (in category 'submorphs - enumerating') -----
+ allMorphsDepthFirstDo: aBlock 
+ 	"Evaluate the given block for all morphs in this composite morph (including the receiver)."
+ 	submorphs do: [:m | m allMorphsDepthFirstDo: aBlock].
+ 	aBlock value: self!

Item was changed:
  ----- Method: Morph>>allMorphsDo: (in category 'submorphs - enumerating') -----
  allMorphsDo: aBlock 
  	"Evaluate the given block for all morphs in this composite morph (including the receiver)."
+ 	self allMorphsDepthFirstDo: aBlock.!
- 	submorphs do: [:m | m allMorphsDo: aBlock].
- 	aBlock value: self!

Item was changed:
  ----- Method: SystemWindow>>beKeyWindow (in category 'top window') -----
  	"Let me be the most important window on the screen. I am at the top and I can have a shadow to get more attention by the user. I am the window that is responsible for window keyboard shortcuts. Also see #isKeyWindow, #activate, and #lookFocused."
  	| oldKeyWindow |
  	self isKeyWindow ifTrue: [^ self].
  	oldKeyWindow := TopWindow.
  	TopWindow := self.
  		unlockWindowDecorations; "here, because all windows might be active anyway"
  		activate; "if not already active, activate now"
  		comeToFront. "key windows are on top"
  	"Change appearance to get noticed."
  	self hasDropShadow: Preferences menuAppearance3d.
  	(self valueOfProperty: #borderWidthWhenActive)
  		ifNotNil: [:bw | self acquireBorderWidth: bw].
  	oldKeyWindow ifNotNil: [:wnd |
  		wnd passivateIfNeeded.
  		"Change appearance to not look prettier than the new key window."
  		wnd hasDropShadow: false.
  		(wnd valueOfProperty: #borderWidthWhenInactive)
  			ifNotNil: [:bw | wnd acquireBorderWidth: bw]].
+ 	self currentEvent isKeyboard ifTrue: [
+ 		self currentHand newKeyboardFocus: self defaultFocusMorph].
  	"Synchronize focus look with position of current hand because any call could have made this window the new key window."
  	self updateFocusLookAtHand.!

Item was added:
+ ----- Method: SystemWindow>>defaultFocusMorph (in category 'focus') -----
+ defaultFocusMorph
+ 	| predicate |
+ 	predicate := (self hasProperty: #defaultFocusMorph)
+ 		ifFalse: [ [:morph | morph wantsKeyboardFocus] ]
+ 		ifTrue: [ | anObject |
+ 			anObject := (self valueOfProperty: #defaultFocusMorph) value.
+ 			anObject isMorph ifTrue: [^ anObject].
+ 			[:morph | morph knownName = anObject] ].
+ 	self allMorphsBreadthFirstDo: [:morph |
+ 		(predicate value: morph) ifTrue: [^ morph]].
+ 	^ nil!

Item was added:
+ ----- Method: SystemWindow>>defaultFocusMorph: (in category 'focus') -----
+ defaultFocusMorph: aMorphOrBlockOrNameOrNil
+ 	self setProperty: #defaultFocusMorph toValue: aMorphOrBlockOrNameOrNil.!

More information about the Squeak-dev mailing list