Sean P. DeNigris wrote
> Issue 6551: [ENH Spec]: Spec-ify DropListModel
> http://code.google.com/p/pharo/issues/detail?id=6551
> 
> Currently:
>       self instantiateModels: #(dropList #DropListModel).
>       
>       item1 := DropListItem named: 'Red morph' do: self redMorphBlock.
>       item2 := DropListItem named: 'Blue morph' do: self blueMorphBlock.
>       item3 := DropListItem named: 'Green morph' do: self greenMorphBlock.
>       
>       dropList items: {item1. item2. item3}.
> 
> I'd prefer if DropLists were uniform with the rest of Spec, namely:
>   I'd have my domain class
>   MyColor>>description
>     ^ nameOfColor
>   
>   dropList
>     items: {myRedColor. myBlueColor. myGreenColor};
>     displayBlock: [ :e | e description, ' morph' ];
>     whenSelectionChanged: [ :e | self showMorphFor: e ].

Now @
https://pharo.fogbugz.com/f/cases/6489/Spec-ify-DropListModel-TextModel
Fix in inbox:
SLICE-Issue-6489-Spec-ify-DropListModel--TextModel-SeanDeNigris.1

It's a little ugly because I wanted to preserve the old raw-string behavior
for now.

Instead of:
colorItems := #('Green' 'Red' 'Yellow') collect: [ :e | DropListItem named:
e do: [] ].
colorModel
    items: colorItems.
And then matching the strings that come back (yuck)...

You can now say:
colorModel
    items: { Color green. Color red. Color yellow };
    displayBlock: [ :e | e name capitalized ].

And then:
colorModel whenSelectedItemChangedDo: [ :color | Transcript show: color
brightness ].

I also uploaded a version for 2.0 to the old
(http://ss3.gemstone.com/ss/PharoInbox/) inbox and at
http://ss3.gemstone.com/ss/PharoSpd for those (like me) who can't wait until
3.0 to use it ;)



-----
Cheers,
Sean
--
View this message in context: 
http://forum.world.st/Spec-DropLists-tp4643694p4681720.html
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.

Reply via email to