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

Marcel Taeumel marcel.taeumel at hpi.de
Fri May 6 10:05:24 UTC 2022


Hi Christoph --

> For instance, when the user chooses an extremely small
> window size or a class has an unlikely high number of variables

First of all, browsing variables does already use #chooseFrom and
not #chooseOptionFrom: because of that.

Secondly, you should not get mixed up in unclear constraints
such as "extremely small window size". There are surely a lot of 
other issues with those. Therefore, we clarify what we can 
control:

800x600 -- preferably using 75% scale factor
1024x768

Those are the "extremely small window sizes" we can control.
Otherwise, the user might even be able to grow the host window
a little bit if necessary. ;-)

Best,
Marcel
Am 04.05.2022 20:13:42 schrieb Thiede, Christoph <christoph.thiede at student.hpi.uni-potsdam.de>:
Hi Marcel,

I see your point in avoiding magic numbers to improve consistency. And I also agree with you that if the dynamically generated list can be expected to not fit into the screen, the application code should not use #chooseOptionFrom:.

Still, I think that automatic fallback code in the UI framework as a last resort would be a nice thing. For instance, when the user chooses an extremely small window size or a class has an unlikely high number of variables:




What would be wrong with trying to improve the layouting before displaying something awkward? (Just like I also think it would be an improvement if #inform: dialogs automatically added a scrollbar when space is low - still, apps should not inform huge texts.) We can still make application code accountable for avoiding these situations based on domain knowledge. But the ExternalDropHandler should not need to check the screen size, for example.

Best,
Christoph
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel
Gesendet: Mittwoch, 4. Mai 2022 14:45:17
An: squeak-dev
Betreff: Re: [squeak-dev] The Trunk: ToolBuilder-Morphic-tpr.312.mcz
 
...and your application code can actually check for that magic number if you really want to and then use either #chooseFrom: or #chooseOptionFrom:. No need to hide such a thing in the library.

Best,
Marcel
Am 04.05.2022 14:41:13 schrieb Marcel Taeumel <marcel.taeumel at hpi.de>:
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/20220506/5178a0e2/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/20220506/5178a0e2/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 15159 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220506/5178a0e2/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 111700 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220506/5178a0e2/attachment-0005.png>


More information about the Squeak-dev mailing list