[squeak-dev] Merge Request: pbKeyboard.1.cs

Marcel Taeumel marcel.taeumel at hpi.de
Fri Nov 26 16:54:11 UTC 2021


Merged.
Am 06.11.2021 21:47:16 schrieb christoph.thiede at student.hpi.uni-potsdam.de <christoph.thiede at student.hpi.uni-potsdam.de>:
==================== Summary ====================

Change Set:        pbKeyboard
Date:            2 November 2021
Author:            Christoph Thiede

This changeset improves keyboard shortcut for preference button in the PreferenceBrowser. You can now select a preference in the browser and press escape to trigger the menu or cmd + (m|b | n | i | c | C) to browse senders/implementors / inspect the preference, or copy its content, resp. Also fixes up a few Law of Demeter violations in PBPreferenceView and improves multilingual support.

=============== Diff ===============

PBPreferenceButtonMorph>>handlesKeyboard: {event handling} · ct 11/1/2021 22:54
+ handlesKeyboard: anEvent
+
+     ^ anEvent isKeystroke

PBPreferenceButtonMorph>>highlightOn {highlighting} · ct 11/1/2021 23:14 (changed)
highlightOn
    
    self color: ((UserInterfaceTheme current get: #selectionColor for: PluggableListMorph) ifNil: [Color gray alpha: 0.1]).

    self label
        color: ((UserInterfaceTheme current get: #selectionTextColor for: PluggableListMorph) ifNil: [Color black]);
        font: (((UserInterfaceTheme current get: #font for: PluggableListMorph) ifNil: [TextStyle defaultFont])
            emphasized: TextEmphasis bold emphasisCode).
    
-     self addExtraControls.
+     self addExtraControls.
+     
+     self currentHand newKeyboardFocus: self.

PBPreferenceButtonMorph>>keyStroke: {event handling} · ct 11/1/2021 23:02
+ keyStroke: anEvent
+
+     ^ self preferenceView keyStroke: anEvent browser: self model

PBPreferenceView>>keyStroke:browser: {user interface} · ct 11/2/2021 15:41
+ keyStroke: anEvent browser: aPreferenceBrowser
+
+     anEvent commandKeyPressed
+         ifFalse: [
+             anEvent keyCharacter = Character escape
+                 ifTrue: [^ self offerPreferenceNameMenu: aPreferenceBrowser].
+             ^ anEvent wasHandled: false].
+     
+     anEvent keyCharacter
+         caseOf: {
+             [$b] -> [aPreferenceBrowser findCategoryFromPreference: self preference].
+             [$c] -> [self copyName].
+             [$C] -> [self copyCode].
+             [$i] -> [self preference inspect].
+             [$m] -> [self browse].
+             [$n] -> [self browseSenders]}
+         otherwise: [anEvent wasHandled: false].

PBPreferenceView>>offerPreferenceNameMenu: {user interface} · ct 11/2/2021 15:44 (changed)
offerPreferenceNameMenu: aPreferenceBrowser
    "the user clicked on a preference name -- put up a menu"

    | aMenu readableName |
    readableName := self preference readableName.
    aMenu := MenuMorph new
        defaultTarget: self preference;
        addTitle: readableName.

    (Preferences okayToChangeProjectLocalnessOf: self preference name) ifTrue:
        [aMenu
            addUpdating: #isProjectLocalString target: self preference action: #toggleProjectLocalness;
-             balloonTextForLastItem: 'Some preferences are best applied uniformly to all projects, and others are best set by each individual project. If this item is checked, then this preference will be printed in bold and will have a separate value for each project'].
+             balloonTextForLastItem: 'Some preferences are best applied uniformly to all projects, and others are best set by each individual project. If this item is checked, then this preference will be printed in bold and will have a separate value for each project' translated].

    aMenu
        addLine;
-         add: 'browse senders' translated
-             target: self systemNavigation
-             selector: #browseAllSelect:name:autoSelect:
-             argumentList: {
-                 [:m | self preference selectors anySatisfy: [:sel | m hasLiteral: sel]].
-                 'Preference senders: {1}' translated format: {self preference name}.
-                 self preference selectors first };
-         balloonTextForLastItem: 'This will open a method-list browser on all methods that the send the preference "'
-             , readableName , '".'.
+         add: 'browse senders (n)' translated
+             action: #browseSenders;
+         balloonTextForLastItem: ('This will open a method-list browser on all methods that the send the preference "{1}".' translated format: {readableName}).
    self preference provider ifNotNil: [
        aMenu
-             add: 'browse implementation' translated
-                 target: ToolSet
-                 selector: #browse:selector:
-                 argumentList: {
-                     self preference provider class.
-                     self preference selectors first };
-             balloonTextForLastItem: 'This will open a browser on the method that stores the preference "' , readableName , '".'].
+             add: 'browse implementation (m)' translated
+                 action: #browse;
+             balloonTextForLastItem: ('This will open a browser on the method that stores the preference "{1}".' translated format: {readableName})].
    aMenu
-         add: 'inspect preference' translated
-             target: self preference
-             selector: #inspect;
-         balloonTextForLastItem: 'This will open an Inspector on the preference "' , readableName , '".'.
+         add: 'inspect preference (i)' translated
+             action: #inspect;
+         balloonTextForLastItem: ('This will open an inspector on the preference "{1}".' translated format: {readableName}).
    aMenu
        addLine;
-         add: 'show category'
+         add: 'show category (b)' translated
            target: aPreferenceBrowser
            selector: #findCategoryFromPreference:
            argument: self preference;
-         balloonTextForLastItem: 'Allows you to find out which category, or categories, this preference belongs to.'.
+         balloonTextForLastItem: 'Allows you to find out which category, or categories, this preference belongs to.' translated.

    Smalltalk isMorphic ifTrue:
        [aMenu
-             add: 'hand me a button for this preference'
+             add: 'hand me a button for this preference' translated
                target: self
                selector: #tearOffButton;
-             balloonTextForLastItem: 'Will give you a button that governs this preference, which you may deposit wherever you wish'].
+             balloonTextForLastItem: 'Will give you a button that governs this preference, which you may deposit wherever you wish' translated].

    aMenu
-         add: 'copy name to clipboard'
-             target: self preference
-             selector: #copyName;
-         balloonTextForLastItem: 'Copy the name of the preference to the text clipboard, so that you can paste into code somewhere'.
+         add: 'copy name to clipboard (c)' translated
+             action: #copyName;
+         balloonTextForLastItem: 'Copy the name of the preference to the text clipboard, so that you can paste into code somewhere' translated.
    aMenu
-         add: 'copy code to clipboard'
-             target: self preference
-             selector: #copyCode;
-         balloonTextForLastItem: 'Copy the code to access the current preference value to the clipboard, so that you can paste into code somewhere'.
+         add: 'copy code to clipboard (C)' translated
+             action: #copyCode;
+         balloonTextForLastItem: 'Copy the code to access the current preference value to the clipboard, so that you can paste into code somewhere' translated.

    aMenu popUpInWorld

PragmaPreference>>browse {browsing} · ct 11/1/2021 22:56
+ browse
+
+     ToolSet
+         browse: self provider class
+         selector: self selectors first.

Preference>>browse {browsing} · ct 11/1/2021 22:56
+ browse
+
+     ToolSet
+         browse: Preferences class
+         selector: self selectors first.

Preference>>browseSenders {browsing} · ct 11/1/2021 22:42
+ browseSenders
+
+     self systemNavigation
+         browseAllSelect: [:m | self selectors anySatisfy: [:sel | m hasLiteral: sel]]
+         name: ('Preference senders: {1}' translated format: {self name})
+         autoSelect: self selectors first.

PreferenceBrowser>>findCategoryFromPreference: {find} · ct 11/2/2021 15:03 (changed)
findCategoryFromPreference: aPreference
    "Find all categories in which the preference occurs"

-     | aMenu|
-     aMenu := MenuMorph new defaultTarget: self.
+     | categories menu |
+     categories := aPreference categoryList.
+     categories size = 0
+         ifTrue: [^ self].
+     categories size = 1
+         ifTrue: [^ self selectedCategory: categories first].
+     
+     menu := MenuMorph new defaultTarget: self.
    aPreference categoryList do:
-         [:aCategory | aMenu add: aCategory target: self selector: #selectedCategory: argument: aCategory].
-     aMenu popUpInWorld
+         [:aCategory | menu add: aCategory target: self selector: #selectedCategory: argument: aCategory].
+     menu popUpInWorld

PreferenceBrowserMorph>>assureKeyboardFocus: {event handling} · ct 11/1/2021 23:14
+ assureKeyboardFocus: aHandMorph
+
+     aHandMorph keyboardFocus = self
+         ifTrue: [^ self].
+     
+     (aHandMorph keyboardFocus notNil and: [aHandMorph keyboardFocus hasOwner: self])
+         ifTrue: [^ self].
+     
+     aHandMorph newKeyboardFocus: self.

PreferenceBrowserMorph>>mouseDownOn:event: {event handling} · ct 11/1/2021 23:13 (changed)
mouseDownOn: aPreferenceView event: anEvent
-     anEvent hand newKeyboardFocus: self preferenceList scroller.
+     self assureKeyboardFocus: anEvent hand.
    anEvent yellowButtonPressed
        ifTrue: [aPreferenceView offerPreferenceNameMenu: self model]

PreferenceView>>browse {user interface} · ct 11/1/2021 22:43
+ browse
+
+     ^ self preference browse

PreferenceView>>browseSenders {user interface} · ct 11/1/2021 22:42
+ browseSenders
+
+     ^ self preference browseSenders


---
Sent from Squeak Inbox Talk [https://github.com/hpi-swa-lab/squeak-inbox-talk]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211126/aace27ea/attachment.html>


More information about the Squeak-dev mailing list