[squeak-dev] The Inbox: Morphic-ct.1786.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Tue Oct 19 13:36:08 UTC 2021


Note that shortcuts implemented via EventKeyChar (or #keyStroke:) use #keyCharacter and should therefore not be combined with #shiftPressed since the SHIFT-key actually modifiers the character delivered. Just use #keyCharacter and the other modifiers (e.g., #controlPressed or #commandPressed).

In this example, SHIFT seems to be ignored in the VM when CTRL is pressed. SHIFT+1 yields $! but CTRL+SHIFT+1 yields $1. This is clearly a bug in the VM.

So, I would rather not make the change as proposed here.

Best,
Marcel

P.S.: Note that this is not the minimal change you could have made to this method to propose your fix. By merging the two checks into a more complex condition, you impaired readability a little bit. At least through my eyes. I would have probably just added a check for #shiftPressed below #isKeystroke and also added some commentary on what the bug here is.
Am 18.10.2021 17:52:43 schrieb commits at source.squeak.org <commits at source.squeak.org>:
A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1786.mcz

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

Name: Morphic-ct.1786
Author: ct
Time: 18 October 2021, 5:52:25.059559 pm
UUID: 322e30d5-aa3f-cb45-843c-c01bf40a00a1
Ancestors: Morphic-ul.1780

Do not invoke docking bar menu via Ctrl + Shift + . Keep this shortcut available for others morphs.

=============== Diff against Morphic-ul.1780 ===============

Item was changed:
----- Method: DockingBarMorph>>filterEvent:for: (in category 'events-processing') -----
filterEvent: aKeyboardEvent for: anObject
"Provide keyboard shortcuts."

| index itemToSelect |
+ (aKeyboardEvent isKeystroke and: [aKeyboardEvent controlKeyPressed] and: [aKeyboardEvent shiftPressed not])
-
- aKeyboardEvent controlKeyPressed
ifFalse: [^ aKeyboardEvent].
+
-
- aKeyboardEvent isKeystroke
- ifFalse: [^ aKeyboardEvent].
-
"Search field."
aKeyboardEvent keyCharacter = $0
ifTrue: [
self searchBarMorph ifNotNil: [ :morph |
morph model activate: aKeyboardEvent in: morph ].
^ aKeyboardEvent ignore "hit!!"].

"Select menu items."
(aKeyboardEvent keyValue
between: $1 asciiValue
and: $9 asciiValue)
ifFalse: [^ aKeyboardEvent].

index := aKeyboardEvent keyValue - $1 asciiValue + 1.
itemToSelect := (self submorphs select: [ :each |
each isMenuItemMorph ])
at: index
ifAbsent: [^ aKeyboardEvent].
+
-
self activate: aKeyboardEvent.
self
selectItem: itemToSelect
event: aKeyboardEvent.
+
-
^ aKeyboardEvent ignore "hit!!"!


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


More information about the Squeak-dev mailing list