[squeak-dev] The Trunk: Morphic-ct.1961.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Wed Apr 6 18:58:29 UTC 2022

> "preferredPosition isMorph" ... this is kind of a badly smelling piece of code there ;-)

+1. But I did not introduce it. ;-)


Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel
Gesendet: Mittwoch, 6. April 2022 20:57:05
An: squeak-dev
Betreff: Re: [squeak-dev] The Trunk: Morphic-ct.1961.mcz

"preferredPosition isMorph" ... this is kind of a badly smelling piece of code there ;-)


Am 06.04.2022 20:16:52 schrieb commits at source.squeak.org <commits at source.squeak.org>:

Christoph Thiede uploaded a new version of Morphic to project The Trunk:

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

Name: Morphic-ct.1961
Author: ct
Time: 6 April 2022, 8:16:10.262385 pm
UUID: a733d275-2b98-5d4c-837c-9eb9c90912ab
Ancestors: Morphic-ct.1960

Tweaks default keyboard focus in dialog windows. Makes sure that for "fill in the blank" dialogs, users can type into the text field even it is not hovered initially. For system windows, avoid focusing a locked morph and beautifies the morph search by using a chained sort function.

=============== Diff against Morphic-ct.1960 ===============

Item was added:
+ ----- Method: DialogWindow>>defaultFocusMorph (in category 'accessing') -----
+ defaultFocusMorph
+ (preferredPosition isMorph and: [preferredPosition wantsKeyboardFocus]) ifTrue: [^ preferredPosition].
+ ^ nil!

Item was changed:
----- Method: DialogWindow>>getUserResponse (in category 'running') -----

| hand world |
self message ifEmpty: [messageMorph delete]. "Do not waste space."
self paneMorph submorphs
ifEmpty: ["Do not waste space and avoid strange button-row wraps."
self paneMorph delete.
self buttonRowMorph wrapDirection: #none].

hand := self currentHand.
world := self currentWorld.

self fullBounds.
self morphicLayerNumber: self class dialogLayer.
self moveToPreferredPosition.
self openInWorld: world.

hand showTemporaryCursor: nil. "Since we are out of context, reset the cursor."

hand keyboardFocus in: [:priorKeyboardFocus |
hand mouseFocus in: [:priorMouseFocus |
self exclusive ifTrue: [hand newMouseFocus: self].
+ hand newKeyboardFocus: self defaultFocusMorph.
- hand newKeyboardFocus: self.

[[self isInWorld] whileTrue: [world doOneSubCycle]]
ifCurtailed: [self cancelDialog].

hand newKeyboardFocus: priorKeyboardFocus.

self flag: #discuss. "Since 2016 we are having this *ping pong* between (a) restoring the prior mouse focus and (b) just clearing it globally. The former solution makes more sense while the latter fixes issues with some modal dialogs. We have to investigate this further."
hand releaseMouseFocus.
"hand newMouseFocus: priorMouseFocus."]].

^ result!

Item was added:
+ ----- Method: FillInTheBlankMorph>>defaultFocusMorph (in category 'accessing') -----
+ defaultFocusMorph
+ ^ self textPane!

Item was changed:
----- Method: SystemWindow>>defaultFocusMorph (in category 'focus') -----

| predicate |
predicate := (self hasProperty: #defaultFocusMorph)
+ ifFalse: [ [:morph | morph isLocked not and: [morph wantsKeyboardFocus]] ]
- ifFalse: [ [:morph | morph wantsKeyboardFocus] ]
ifTrue: [ | anObject |
anObject := (self valueOfProperty: #defaultFocusMorph) value.
anObject isMorph ifTrue: [^ anObject].
[:morph | morph knownName = anObject] ].
allMorphsBreadthFirstDo: [:morph | (predicate value: morph) ifTrue: [^ morph]]
+ sorted: #top ascending, #left ascending.
- sorted: [:a :b | a top < b top or: [a top = b top and: [a left <= b left]]].
^ nil!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220406/3629106e/attachment.html>

More information about the Squeak-dev mailing list