<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">Hi Christoph --<div class="mb_sig"></div>
<div><br></div><div>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:.</div><div><br></div><div>No magic number here anymore.</div><div><br></div><div>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.</div><div><br></div><div>#chooseOptionFrom: is only for hard-coded lists of fixed options where you know what's happening and thus can design the appearance through buttons.</div><div><br></div><div>Best,</div><div>Marcel</div><blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
<p style="color: #AAAAAA; margin-top: 10px;">Am 04.05.2022 14:29:48 schrieb Thiede, Christoph <christoph.thiede@student.hpi.uni-potsdam.de>:</p><div style="font-family:Arial,Helvetica,sans-serif">
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif">
<p><span style="font-family: Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size: 16px">Very nice! May I suggest that we fall back to traditional #chooseFrom: if
we have more than, </span><span style="font-family: Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size: 16px">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. :-)</span><br>
</p>
<p><span style="font-family: Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size: 16px"><br>
</span></p>
<p><span style="font-family: Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size: 16px">Best,</span></p>
<p><span style="font-family: Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size: 16px">Christoph</span></p>
<p><span style="font-family: Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size: 16px"><br>
</span></p>
<p><span style="font-family: Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size: 16px"><img size="9948" id="x_img765921" tabindex="0" style="max-width:99.9%" src="cid:07c3b015-332d-4240-bfea-753a512a6b01"></img><br>
</span></p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif;color: #000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von commits@source.squeak.org <commits@source.squeak.org><br>
<b>Gesendet:</b> Dienstag, 19. April 2022 20:59:20<br>
<b>An:</b> squeak-dev@lists.squeakfoundation.org; packages@lists.squeakfoundation.org<br>
<b>Betreff:</b> [squeak-dev] The Trunk: ToolBuilder-Morphic-tpr.312.mcz</span>
<div> </div>
</div>
</div>
<span style="font-size: 10pt"><span style="font-size: 10pt">
<div class="PlainText">tim Rowledge uploaded a new version of ToolBuilder-Morphic to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/ToolBuilder-Morphic-tpr.312.mcz">http://source.squeak.org/trunk/ToolBuilder-Morphic-tpr.312.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: ToolBuilder-Morphic-tpr.312<br>
Author: tpr<br>
Time: 19 April 2022, 11:59:19.483381 am<br>
UUID: 3b32b25c-7cdf-4307-85af-84b0dfd08f1d<br>
Ancestors: ToolBuilder-Morphic-mt.311<br>
<br>
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<br>
<br>
=============== Diff against ToolBuilder-Morphic-mt.311 ===============<br>
<br>
Item was changed:<br>
----- Method: MorphicUIManager>>chooseFrom:lines:title: (in category 'ui requests') -----<br>
chooseFrom: aList lines: linesArray title: aString <br>
"Choose an item from the given list. Answer the index of the selected item. Cancel value is 0.<br>
+ If you are choosing an option from a short list (see for example ZipArchiveMember>>#extractInDirectory:overwrite:) use MorphicUIManager>>#chooseOptionFrom:lines:title: instead."<br>
+ self<br>
+ askForProvidedAnswerTo: aString<br>
+ ifSupplied:<br>
+ [:answer | <br>
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ 0].<br>
+ ^ aList indexOf: answer].<br>
<br>
- There are several (historical) reasons for building a button dialog instead of a list chooser for small lists:<br>
- 1) Unfortunately, there is existing code that uses this call to create simple confirmation dialogs with a list of #(yes no cancel).<br>
- 2) Unfortunately, there is existing code that uses this call to mimick a drop-down menu with a (compact) pop-up menu."<br>
- self askForProvidedAnswerTo: aString ifSupplied: [:answer | <br>
- (answer = #cancel or: [answer isNil]) ifTrue: [^ 0].<br>
- ^ aList indexOf: answer].<br>
- <br>
aList ifEmpty: [^ 0].<br>
- aList size <= 7 ifTrue: [<br>
- | dialog |<br>
- dialog := DialogWindow new<br>
- title: ListChooser defaultTitle;<br>
- message: aString;<br>
- filterEnabled: true;<br>
- autoCancel: true; "Like a pop-up menu, click anywhere to dismiss."<br>
- yourself.<br>
- aList withIndexDo: [:ea :index |<br>
- dialog createButton: ea value: index].<br>
- dialog selectedButtonIndex: 1.<br>
- ^ dialog getUserResponseAtHand ifNil: [0]].<br>
- <br>
^ ListChooser chooseFrom: aList title: aString!<br>
<br>
Item was changed:<br>
----- Method: MorphicUIManager>>chooseFrom:values:lines:title: (in category 'ui requests') -----<br>
chooseFrom: labelList values: valueList lines: linesArray title: aString <br>
"Choose an item from the given list. Answer the selected item."<br>
<br>
| index |<br>
+ self<br>
+ askForProvidedAnswerTo: aString<br>
+ ifSupplied:<br>
+ [:answer | <br>
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ nil].<br>
+ ^ valueList at: (labelList indexOf: answer) ifAbsent:<br>
+ [answer isNumber <br>
+ ifTrue: [valueList at: answer ifAbsent: [nil]]<br>
+ ifFalse: [nil]]].<br>
- self askForProvidedAnswerTo: aString ifSupplied: [:answer | <br>
- (answer = #cancel or: [answer isNil]) ifTrue: [^ nil].<br>
- ^ valueList at: (labelList indexOf: answer) ifAbsent: [<br>
- answer isNumber <br>
- ifTrue: [valueList at: answer ifAbsent: [nil]]<br>
- ifFalse: [nil]]].<br>
<br>
index := self chooseFrom: labelList lines: linesArray title: aString.<br>
^ index = 0<br>
ifTrue: [ nil ]<br>
ifFalse: [ valueList at: index ]!<br>
<br>
Item was added:<br>
+ ----- Method: MorphicUIManager>>chooseOptionFrom:lines:title: (in category 'ui requests') -----<br>
+ chooseOptionFrom: aList lines: linesArray title: aString <br>
+ | dialog |<br>
+ "Choose an option from the given list. Answer the index of the selected item. Cancel value is 0.<br>
+ <br>
+ There are several (historical) reasons for needing a button dialog instead of a list chooser for small lists:<br>
+ 1) Unfortunately, there is existing code that uses this call to create simple confirmation dialogs with a list of #(yes no cancel).<br>
+ 2) Unfortunately, there is existing code that uses this call to mimic a drop-down menu with a (compact) pop-up menu.<br>
+ This method *only* provides the short list UI"<br>
+ self<br>
+ askForProvidedAnswerTo: aString<br>
+ ifSupplied:<br>
+ [:answer | <br>
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ 0].<br>
+ ^ aList indexOf: answer].<br>
+ <br>
+ aList ifEmpty: [^ 0].<br>
+ dialog := DialogWindow new<br>
+ title: ListChooser defaultTitle;<br>
+ message: aString;<br>
+ filterEnabled: true;<br>
+ autoCancel: true; "Like a pop-up menu, click anywhere to dismiss."<br>
+ yourself.<br>
+ aList withIndexDo: <br>
+ [:ea :index |<br>
+ dialog createButton: ea value: index].<br>
+ dialog selectedButtonIndex: 1.<br>
+ ^ dialog getUserResponseAtHand ifNil: [0]!<br>
<br>
<br>
</div>
</span></span>
</div></blockquote></div>