[Pharo-project] Spec DropLists
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 ]. I'd prefer not to even know that DropListItem exists, and have the model take care of it for me. Something like: DropListModel>>items: aList "Populate the drop list with a list of objects" | items | items := aList collect: [ :e | DropListItem named: e printString do: [ ] ]. listHolder contents: items. Incidentally, #whenSelectionChanged: exists for DropListModels, but is broken. When an item is chosen from the drop list, the announcement received by this block has both new and old contents set to nil: Issue 6550: [BUG Spec]: DropListModel>>whenSelectionChanged: http://code.google.com/p/pharo/issues/detail?id=6550 Cheers, Sean -- View this message in context: http://forum.world.st/Spec-DropLists-tp4643694.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Thanks sean Ben is on holidays for two weeks. So I imagine that he will not read the mailing-list. Stef On Aug 9, 2012, at 8:14 PM, 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 ].
I'd prefer not to even know that DropListItem exists, and have the model take care of it for me. Something like: DropListModel>>items: aList "Populate the drop list with a list of objects"
| items | items := aList collect: [ :e | DropListItem named: e printString do: [ ] ]. listHolder contents: items.
Incidentally, #whenSelectionChanged: exists for DropListModels, but is broken. When an item is chosen from the drop list, the announcement received by this block has both new and old contents set to nil: Issue 6550: [BUG Spec]: DropListModel>>whenSelectionChanged: http://code.google.com/p/pharo/issues/detail?id=6550
Cheers, Sean
-- View this message in context: http://forum.world.st/Spec-DropLists-tp4643694.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
+1 for me I had exactly the same experience with DropLists Le 9 août 2012 à 20:14, Sean P. DeNigris a écrit :
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 ].
I'd prefer not to even know that DropListItem exists, and have the model take care of it for me. Something like: DropListModel>>items: aList "Populate the drop list with a list of objects"
| items | items := aList collect: [ :e | DropListItem named: e printString do: [ ] ]. listHolder contents: items.
Incidentally, #whenSelectionChanged: exists for DropListModels, but is broken. When an item is chosen from the drop list, the announcement received by this block has both new and old contents set to nil: Issue 6550: [BUG Spec]: DropListModel>>whenSelectionChanged: http://code.google.com/p/pharo/issues/detail?id=6550
Cheers, Sean
-- View this message in context: http://forum.world.st/Spec-DropLists-tp4643694.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
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.
I did not check but we should avoid isKindOf: and we should avoid different protocol that after leads to ugly code.
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.
participants (4)
-
Christophe Demarey -
Sean P. DeNigris -
stephane ducasse -
Stéphane Ducasse