[squeak-dev] The Trunk: ToolBuilder-Morphic-tpr.312.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Wed May 4 12:41:13 UTC 2022


Hi Christoph --

Haha. ;-) 10 or 15 is not better than the original 7. Regardless of the direction. The application code has to choose between chooseFrom: and chooseOptionFrom:.

No magic number here anymore.

For your dynamically generated list, you should always use #chooseFrom:, not #chooseOptionFrom:. While you would still get an actual list for less than 10 items, it seems to be the better trade off and a more consistent user experience.

#chooseOptionFrom: is only for hard-coded lists of fixed options where you know what's happening and thus can design the appearance through buttons.

Best,
Marcel
Am 04.05.2022 14:29:48 schrieb Thiede, Christoph <christoph.thiede at student.hpi.uni-potsdam.de>:
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


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 [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/1d4b8db0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 9948 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220504/1d4b8db0/attachment-0001.png>


More information about the Squeak-dev mailing list