[squeak-dev] The Trunk: ToolBuilder-Morphic-tpr.312.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Apr 19 18:59:20 UTC 2022
tim Rowledge uploaded a new version of ToolBuilder-Morphic to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Morphic-tpr.312.mcz
==================== Summary ====================
Name: ToolBuilder-Morphic-tpr.312
Author: tpr
Time: 19 April 2022, 11:59:19.483381 am
UUID: 3b32b25c-7cdf-4307-85af-84b0dfd08f1d
Ancestors: ToolBuilder-Morphic-mt.311
Add a ToolBuilder ability to show a list of options - typically a small number, maybe with a cancel button etc - as opposed to an arbitrary list of values. This separates it out from the chooseFrom:... protocol
=============== Diff against ToolBuilder-Morphic-mt.311 ===============
Item was changed:
----- Method: MorphicUIManager>>chooseFrom:lines:title: (in category 'ui requests') -----
chooseFrom: aList lines: linesArray title: aString
"Choose an item from the given list. Answer the index of the selected item. Cancel value is 0.
+ If you are choosing an option from a short list (see for example ZipArchiveMember>>#extractInDirectory:overwrite:) use MorphicUIManager>>#chooseOptionFrom:lines:title: instead."
+ self
+ askForProvidedAnswerTo: aString
+ ifSupplied:
+ [:answer |
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ 0].
+ ^ aList indexOf: answer].
- There are several (historical) reasons for building a button dialog instead of a list chooser for small lists:
- 1) Unfortunately, there is existing code that uses this call to create simple confirmation dialogs with a list of #(yes no cancel).
- 2) Unfortunately, there is existing code that uses this call to mimick a drop-down menu with a (compact) pop-up menu."
- self askForProvidedAnswerTo: aString ifSupplied: [:answer |
- (answer = #cancel or: [answer isNil]) ifTrue: [^ 0].
- ^ aList indexOf: answer].
-
aList ifEmpty: [^ 0].
- aList size <= 7 ifTrue: [
- | dialog |
- dialog := DialogWindow new
- title: ListChooser defaultTitle;
- message: aString;
- filterEnabled: true;
- autoCancel: true; "Like a pop-up menu, click anywhere to dismiss."
- yourself.
- aList withIndexDo: [:ea :index |
- dialog createButton: ea value: index].
- dialog selectedButtonIndex: 1.
- ^ dialog getUserResponseAtHand ifNil: [0]].
-
^ ListChooser chooseFrom: aList title: aString!
Item was changed:
----- Method: MorphicUIManager>>chooseFrom:values:lines:title: (in category 'ui requests') -----
chooseFrom: labelList values: valueList lines: linesArray title: aString
"Choose an item from the given list. Answer the selected item."
| index |
+ self
+ askForProvidedAnswerTo: aString
+ ifSupplied:
+ [:answer |
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ nil].
+ ^ valueList at: (labelList indexOf: answer) ifAbsent:
+ [answer isNumber
+ ifTrue: [valueList at: answer ifAbsent: [nil]]
+ ifFalse: [nil]]].
- self askForProvidedAnswerTo: aString ifSupplied: [:answer |
- (answer = #cancel or: [answer isNil]) ifTrue: [^ nil].
- ^ valueList at: (labelList indexOf: answer) ifAbsent: [
- answer isNumber
- ifTrue: [valueList at: answer ifAbsent: [nil]]
- ifFalse: [nil]]].
index := self chooseFrom: labelList lines: linesArray title: aString.
^ index = 0
ifTrue: [ nil ]
ifFalse: [ valueList at: index ]!
Item was added:
+ ----- Method: MorphicUIManager>>chooseOptionFrom:lines:title: (in category 'ui requests') -----
+ chooseOptionFrom: aList lines: linesArray title: aString
+ | dialog |
+ "Choose an option from the given list. Answer the index of the selected item. Cancel value is 0.
+
+ There are several (historical) reasons for needing a button dialog instead of a list chooser for small lists:
+ 1) Unfortunately, there is existing code that uses this call to create simple confirmation dialogs with a list of #(yes no cancel).
+ 2) Unfortunately, there is existing code that uses this call to mimic a drop-down menu with a (compact) pop-up menu.
+ This method *only* provides the short list UI"
+ self
+ askForProvidedAnswerTo: aString
+ ifSupplied:
+ [:answer |
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ 0].
+ ^ aList indexOf: answer].
+
+ aList ifEmpty: [^ 0].
+ dialog := DialogWindow new
+ title: ListChooser defaultTitle;
+ message: aString;
+ filterEnabled: true;
+ autoCancel: true; "Like a pop-up menu, click anywhere to dismiss."
+ yourself.
+ aList withIndexDo:
+ [:ea :index |
+ dialog createButton: ea value: index].
+ dialog selectedButtonIndex: 1.
+ ^ dialog getUserResponseAtHand ifNil: [0]!
More information about the Squeak-dev
mailing list
|