Skip to content

Instantly share code, notes, and snippets.

@nicoknoll
Created May 21, 2016 18:56
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 nicoknoll/17234879dc4f445861520db8e5846b05 to your computer and use it in GitHub Desktop.
Save nicoknoll/17234879dc4f445861520db8e5846b05 to your computer and use it in GitHub Desktop.
PluggableListMorph subclass: #STweetPluggableListMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Project08-Core'
listItemHeight
"This should be cleaned up. The list should get spaced by this
parameter. "
^ 100
-------
Object subclass: #STweetList
instanceVariableNames: 'list selectedIndex'
classVariableNames: ''
poolDictionaries: ''
category: 'Project08-Core'
getListMorph
| aListMorph |
aListMorph := STweetPluggableListMorph
on: self
list: #list
selected: #listIndex
changeSelected: #listIndex:
menu: #listMenu:.
"I am the model that has a list to display"
"This is how the morph gets the list from me"
"This is how the morph knows which item to highlight"
"This is how the morph informs me of a user selection"
"This is how the morph requests a menu for the list"
aListMorph color: Color white.
^ aListMorph
initialize
list := #('bla' 'bla' )
asSortedCollection: [:a :b | a = b].
selectedIndex := 1
list
^ list
listIndex
^ selectedIndex
listIndex: anInteger
selectedIndex := anInteger.
self changed: #listIndex
listMenu: aMenu
| targetClass differentMenu className |
className := list
at: selectedIndex
ifAbsent: [^ aMenu
add: 'nothing selected'
target: self
selector: #beep].
targetClass := Smalltalk
at: className
ifAbsent: [^ aMenu
add: 'that class is history!!'
target: self
selector: #beep].
differentMenu := DumberMenuMorph new.
"avoid the retargeting business"
differentMenu
add: 'browse'
target: targetClass
selector: #browse;
add: 'inspect'
target: targetClass
selector: #inspect;
add: 'explore'
target: targetClass
selector: #explore.
^ differentMenu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment