Marcel Taeumel uploaded a new version of ToolBuilder-Morphic to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Morphic-mt.203.mcz ==================== Summary ==================== Name: ToolBuilder-Morphic-mt.203 Author: mt Time: 18 December 2017, 8:06:43.076418 am UUID: e831529c-4e71-ca41-9198-74830ef1adb3 Ancestors: ToolBuilder-Morphic-jr.202 More comments to document more existing quirks. :-) =============== Diff against ToolBuilder-Morphic-jr.202 =============== Item was changed: ----- Method: ListChooser>>buildWith: (in category 'building') ----- buildWith: builder | dialogSpec searchBarHeight listSpec fieldSpec | searchBarHeight := Preferences standardDefaultTextFont height * 1.75. dialogSpec := builder pluggableDialogSpec new model: self; title: #title; closeAction: #closed; extent: self initialExtent; + autoCancel: true; "Behave like a pop-up menu. Historical reasons." - autoCancel: true; "behave like a pop-up menu" children: OrderedCollection new; buttons: OrderedCollection new; yourself. listSpec := builder pluggableListSpec new. listSpec model: self; list: #items; getIndex: #selectedIndex; setIndex: #selectedIndex:; doubleClick: #accept; "keystrokePreview: #keyStrokeFromList:;" autoDeselect: false; filterableList: true; clearFilterAutomatically: false; name: #list; frame: (LayoutFrame fractions: (0@0 corner: 1@1) offsets: (0@searchBarHeight corner: 0@0)). dialogSpec children add: listSpec. fieldSpec := builder pluggableInputFieldSpec new. fieldSpec model: self; getText: #searchText; editText: #searchText:; setText: #acceptText:; selection: #textSelection; menu: nil; indicateUnacceptedChanges: false; askBeforeDiscardingEdits: false; help: (self addAllowed ifTrue: ['Type new or filter existing...' translated] ifFalse: ['Type to filter existing...' translated]); frame: (LayoutFrame fractions: (0@0 corner: 1@0) offsets: (0@0 corner: 0@searchBarHeight)). dialogSpec children add: fieldSpec. "Buttons" dialogSpec buttons add: ( builder pluggableButtonSpec new model: self; label: #acceptLabel; action: #accept; enabled: #canAcceptOrAdd; color: #acceptColor). dialogSpec buttons add: ( builder pluggableButtonSpec new model: self; label: 'Cancel'; action: #cancel; color: #cancelColor). dialogMorph := builder build: dialogSpec. dialogMorph addKeyboardCaptureFilter: self. listMorph := builder widgetAt: #list. listMorph allowEmptyFilterResult: true. ^ dialogMorph! 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. - "Choose an item from the given list. Answer the index of the selected item." + 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." + aList ifEmpty: [^ 0]. aList size <= 7 ifTrue: [ | dialog | dialog := DialogWindow new title: 'Please Choose'; message: aString; filterEnabled: true; + autoCancel: true; "Like a pop-up menu, click anywhere to dismiss." - autoCancel: true; yourself. aList doWithIndex: [:ea :index | dialog createButton: ea value: index]. dialog selectedButtonIndex: 1. ^ dialog getUserResponseAtHand ifNil: [0]]. ^ ListChooser chooseFrom: aList title: aString! |
Free forum by Nabble | Edit this page |