[squeak-dev] The Trunk: PreferenceBrowser-mt.119.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Nov 26 16:52:18 UTC 2021


Marcel Taeumel uploaded a new version of PreferenceBrowser to project The Trunk:
http://source.squeak.org/trunk/PreferenceBrowser-mt.119.mcz

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

Name: PreferenceBrowser-mt.119
Author: mt
Time: 26 November 2021, 5:52:19.338058 pm
UUID: 690c159d-3ed5-c245-a63d-6bc8eb45593e
Ancestors: PreferenceBrowser-mt.118

Merges and revises pbKeyboard.1.cs. Thanks to Christoph (ct) for the idea!

Original comment: "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."

Plus, the preference list now honors the #menuRequestUpdatesSelection preference. And yellow-click finally works and shows the preference menu.

Note that I kept the style of dispatching events from buttons to the browser as configured in #newPreferencesButtonFor:. So, I did not follow the changeset's idea of implementing #keyStroke: in PBPreferenceButtonMorph. If we wanted to actually refactor this tool, it would take longer.

Also note that MorphicEvent >> #wasHandled: is not public! It belongs to internal event-dispatching logic. Clients should never mess with this flag except when overwriting #handle*: methods.

Please restart your preference browser. :o)

=============== Diff against PreferenceBrowser-mt.118 ===============

Item was changed:
  ----- Method: PBPreferenceButtonMorph>>highlightOn (in category 'highlighting') -----
  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 currentHand newKeyboardFocus: self.!
- 	self addExtraControls.!

Item was changed:
  ----- Method: PBPreferenceView>>offerPreferenceNameMenu: (in category 'user interface') -----
  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' translated].
- 			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'].
  
  	aMenu
  		addLine;
+ 		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}).
- 		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 , '".'.
  	self preference provider ifNotNil: [
  		aMenu
+ 			add: 'browse implementation (m)' translated
+ 				action: #browse;
+ 			balloonTextForLastItem: ('This will open a browser on the method that stores the preference "{1}".' translated format: {readableName})].
- 			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 , '".'].
  	aMenu
+ 		add: 'inspect preference (i)' translated
+ 			action: #inspect;
+ 		balloonTextForLastItem: ('This will open an inspector on the preference "{1}".' translated format: {readableName}).
- 		add: 'inspect preference' translated
- 			target: self preference
- 			selector: #inspect;
- 		balloonTextForLastItem: 'This will open an Inspector on the preference "' , readableName , '".'.
  	aMenu
  		addLine;
+ 		add: 'show category (b)' translated
- 		add: 'show category'
  			target: aPreferenceBrowser
  			selector: #findCategoryFromPreference:
  			argument: self preference;
+ 		balloonTextForLastItem: 'Allows you to find out which category, or categories, this preference belongs to.' translated.
- 		balloonTextForLastItem: 'Allows you to find out which category, or categories, this preference belongs to.'.
  
  	Smalltalk isMorphic ifTrue:
  		[aMenu
+ 			add: 'hand me a button for this preference' translated
- 			add: 'hand me a button for this preference'
  				target: self
  				selector: #tearOffButton;
+ 			balloonTextForLastItem: 'Will give you a button that governs this preference, which you may deposit wherever you wish' translated].
- 			balloonTextForLastItem: 'Will give you a button that governs this preference, which you may deposit wherever you wish'].
  
  	aMenu
+ 		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.
- 		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'.
  	aMenu
+ 		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.
- 		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'.
  
  	aMenu popUpInWorld!

Item was changed:
  ----- Method: PreferenceBrowser>>findCategoryFromPreference: (in category 'find') -----
  findCategoryFromPreference: aPreference
  	"Find all categories in which the preference occurs"
  
+ 	| categories menu | 
+ 	categories := aPreference categoryList.
+ 	categories size = 0
+ 		ifTrue: [^ self].
+ 	categories size = 1
+ 		ifTrue: [^ self selectedCategory: categories first].
+ 	
+ 	menu := MenuMorph new defaultTarget: self.
- 	| aMenu| 
- 	aMenu := MenuMorph new defaultTarget: self.
  	aPreference categoryList do:
+ 		[:aCategory | menu add: aCategory target: self selector: #selectedCategory: argument: aCategory].
+ 	menu popUpInWorld!
- 		[:aCategory | aMenu add: aCategory target: self selector: #selectedCategory: argument: aCategory].
- 	aMenu popUpInWorld!

Item was removed:
- ----- Method: PreferenceBrowserMorph>>keyPressed: (in category 'event handling') -----
- keyPressed: anEvent
- 	self selectedCategory 
- 		ifNil: [^self].
- 	anEvent keyValue = 30
- 		ifTrue: [^self upKeyPressed: anEvent].
- 	anEvent keyValue = 31
- 		ifTrue: [^self downKeyPressed: anEvent].
- 	anEvent keyValue = 1 
- 		ifTrue: [^self homeKeyPressed: anEvent].
- 	anEvent keyValue = 4
- 		ifTrue: [^self endKeyPressed: anEvent].
- 	anEvent keyValue = 11
- 		ifTrue: [^self pageUpKeyPressed: anEvent].
- 	anEvent keyValue = 12
- 		ifTrue: [^self pageDownKeyPressed: anEvent].
- 	self basicKeyPressed: anEvent.!

Item was added:
+ ----- Method: PreferenceBrowserMorph>>keyPressedOn:event: (in category 'event handling') -----
+ keyPressedOn: aPreferenceView event: anEvent
+ 
+ 	anEvent commandKeyPressed
+ 		ifFalse: [
+ 			anEvent keyValue caseOf: {
+ 				[27] -> [aPreferenceView offerPreferenceNameMenu: self model].
+ 				[30] -> [self upKeyPressed: anEvent].
+ 				[31] -> [self downKeyPressed: anEvent].
+ 				[1] -> [self homeKeyPressed: anEvent].
+ 				[4] -> [self endKeyPressed: anEvent].
+ 				[11] -> [self pageUpKeyPressed: anEvent].
+ 				[12] -> [self pageDownKeyPressed: anEvent] }
+ 					otherwise: [self basicKeyPressed: anEvent].
+ 				^ self].
+ 	
+ 	anEvent keyCharacter
+ 		caseOf: {
+ 			[$b] -> [self model findCategoryFromPreference: aPreferenceView preference].
+ 			[$c] -> [aPreferenceView copyName].
+ 			[$C] -> [aPreferenceView copyCode].
+ 			[$i] -> [aPreferenceView preference inspect].
+ 			[$m] -> [aPreferenceView browse].
+ 			[$n] -> [aPreferenceView browseSenders]}
+ 		otherwise: [].!

Item was changed:
  ----- Method: PreferenceBrowserMorph>>mouseDownOn:event: (in category 'event handling') -----
  mouseDownOn: aPreferenceView event: anEvent
+ 
- 	anEvent hand newKeyboardFocus: self preferenceList scroller.
  	anEvent yellowButtonPressed
+ 		ifTrue: [self selectedPreferenceButton preferenceView offerPreferenceNameMenu: self model].!
- 		ifTrue: [aPreferenceView offerPreferenceNameMenu: self model]!

Item was changed:
  ----- Method: PreferenceBrowserMorph>>newPreferenceButtonFor: (in category 'submorphs - preference list') -----
  newPreferenceButtonFor: aPreference 
  	| button |
  	button := PBPreferenceButtonMorph preference: aPreference model: self model.
  	button 
  		on: #mouseDown
  		send: #value:
  		to: 
  			[:anEvent | 
+ 			(anEvent yellowButtonPressed not
+ 				or: [PluggableListMorph menuRequestUpdatesSelection
+ 					and: [button ~= self selectedPreferenceButton]])
+ 						ifTrue: [
+ 							anEvent hand newKeyboardFocus: button.
+ 							self selectedPreference: aPreference].
+ 			self mouseDownOn: button preferenceView event: anEvent];
+ 		on: #keyStroke
+ 		send: #value:
+ 		to: [:anEvent |self keyPressedOn: button preferenceView event: anEvent].
+ 				
- 			self
- 				selectedPreference: aPreference;
- 				mouseDownOn: button preferenceView event: anEvent].
  	^button!

Item was changed:
  ----- Method: PreferenceBrowserMorph>>preferenceList (in category 'submorphs - preference list') -----
  preferenceList 
  	^preferenceList ifNil:
  		[preferenceList := ScrollPane new
  			vResizing: #spaceFill;
  			hResizing: #spaceFill;
  			layoutFrame: (LayoutFrame fractions: (0.25 at 0 corner: 1 at 1) offsets: (4 at 0 corner: 0 at 0)).
  		preferenceList scroller
- 			on: #keyStroke send: #keyPressed: to: self;
  			changeTableLayout.
  		preferenceList.]!

Item was changed:
  ----- Method: PreferenceBrowserMorph>>selectedPreferenceButton (in category 'submorphs - preference list') -----
  selectedPreferenceButton
+ 	^(self preferenceListInnerPanel submorphs at: self selectedPreferenceIndex ifAbsent: [nil])!
- 	^(self preferenceListInnerPanel submorphs at: self selectedPreferenceIndex)!

Item was added:
+ ----- Method: PreferenceBrowserMorph>>yellowButtonActivity: (in category 'event handling') -----
+ yellowButtonActivity: shiftPressed
+ 	"Ignore. See mouseDownOn:event:."!

Item was added:
+ ----- Method: PreferenceView>>browse (in category 'user interface') -----
+ browse
+ 
+ 	^ self preference browse!

Item was added:
+ ----- Method: PreferenceView>>browseSenders (in category 'user interface') -----
+ browseSenders
+ 
+ 	^ self preference browseSenders!



More information about the Squeak-dev mailing list