Skip to content

Instantly share code, notes, and snippets.

@BenjaminVanRyseghem
Created March 2, 2014 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenjaminVanRyseghem/9306328 to your computer and use it in GitHub Desktop.
Save BenjaminVanRyseghem/9306328 to your computer and use it in GitHub Desktop.
How to make a list render some custom models -- see http://j.mp/1fzQ0HQ
items := (1 to: 5) collect: [ :index || model |
model := DynamicComposableModel new
instantiateModels: #(
nameLabel LabelModel
address LabelModel
button ButtonModel ).
model nameLabel label: 'Name'.
model address label: 'Address'.
model button
label: nil;
icon: Smalltalk ui icons smallCancelIcon.
model layout: (SpecLayout composed
newColumn: [ :c |
c add: #nameLabel height: model class buttonHeight.
c add: #address height: model class buttonHeight.
c newRow: [ :r |
r
newColumn: [ :col | ];
add: #button width: model class buttonWidth ] height: model class buttonHeight]).
model ].
"items first buildWithSpec."
model := ListModel new.
model items: items.
model displayBlock: [ :e | e
extent: 200@100;
yourself ].
model openWithSpec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment