[squeak-dev] The Trunk: ToolBuilder-Morphic-tpr.312.mcz
Thiede, Christoph
Christoph.Thiede at student.hpi.uni-potsdam.de
Wed May 4 12:29:36 UTC 2022
Very nice! May I suggest that we fall back to traditional #chooseFrom: if we have more than, let's say, 10 or 15 options? In some scenarios, options might be generated dynamically, and in these cases, a scrollable list would still scale better. :-)
Best,
Christoph
[cid:07c3b015-332d-4240-bfea-753a512a6b01]
________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Dienstag, 19. April 2022 20:59:20
An: squeak-dev at lists.squeakfoundation.org; packages at lists.squeakfoundation.org
Betreff: [squeak-dev] The Trunk: ToolBuilder-Morphic-tpr.312.mcz
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]!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220504/b583c24d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 9948 bytes
Desc: pastedImage.png
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220504/b583c24d/attachment.png>
More information about the Squeak-dev
mailing list
|