Still problems!Re: (newbee) Problem with PluggableListMorph

Hernan Tylim htylim at yahoo.com.ar
Thu Nov 10 22:20:01 UTC 2005


Hi Marcus,

Attached you will find a very silly example to help you understand how 
PluggableListMorph works.

Just start an image and open a FileList window, look for this .st and 
select the "file-in" option.

This changeset has only a class named PLMExample. Look it in a class 
browser.

This class is your application model. It has an OrderedCollection and a 
number to hold which item is the currently selected one.

This class also has accessors to access your application's data. But 
more importantly look the setters (the #selectedItemIndex: and #add: 
methods). Note how all these methods calls #changed. This is to notify 
all "monitoring" PluggableListMorph that data on your application has 
changed.

I also added a #removeSelectedItem method which will remove an item and 
update the list. I read that that was your problem.

To run the example open a Workspace and select all the text that follows 
and press alt+d (do it)

| example |
example := PLMExample new.
example asMorph openInWindow.
example asMorph openInWindow.
example inspect.

Note that here you are creating one model and opening 2 views. This is 
to highlight how works the decoupling of the view (the 
PluggableListMorph) and the model (PLMExample).

Also note that the 2 windows will probably be overlapped, just move one 
with your mouse and start using the list.

The inspector that you open here is to allow you to manually add and 
remove elements. Try to evaluate this on the inspector:

self removeSelected

Hope it helps.

regards,
Hernán


Marcus Pedersén wrote:
> After I have changed the list in my PluggableListMorph with pLM list: 
> newList.
> I sent the message changed to my PluggableListMorph, to my SystemWindow, 
> to my Morph ( not all in once) and what happens is that the list in my 
> PluggableListMorph is updated with the missing item and the GUI remains 
> the same. I want it the oposite way.
> Please help!
> Marcus
> ----- Original Message ----- From: "karl" <karl.ramberg at chello.se>
> To: "The general-purpose Squeak developers list" 
> <squeak-dev at lists.squeakfoundation.org>
> Sent: Wednesday, November 09, 2005 9:04 PM
> Subject: Re: (newbee) Problem with PluggableListMorph
> 
> 
>> Marcus Pedersén wrote:
>>
>>> Hi!
>>> I have a problem with a PluggableListMorph. If I remove an item in my 
>>> list the GUI is not updated and still shows the removed item.
>>> Perhaps I'm using the wrong methods?
>>> a PluggableListMorph (pLM).
>>>  | collection |
>>> collection := pLM getList.
>>> collection copyWithoutIndex: (pLM getCurrentSelectionIndex).
>>> pLM list: collection.
>>>  If I inspectIt (the code) I see that the removed item is gone in the 
>>> list and if I inspect on the GUI I see that the item is gone as well.
>>> But it is still present in the visual list(GUI). For some reason the 
>>> GUI is not updated.
>>> What am I doing wrong?
>>>  Many thanks in advance!
>>> Marcus
>>>
>>> ------------------------------------------------------------------------
>>>
>>>
>>>
>> It needs to be told to update it self, like 'self changed' or 
>> something similar.
>> Karl
>>
>>
>>
> 
> 
> 
> 
-------------- next part --------------
'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 10 November 2005 at 7:04:07 pm'!
Object subclass: #PLMExample
	instanceVariableNames: 'list selectedItemIndex'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'test'!

!PLMExample methodsFor: 'as yet unclassified' stamp: 'hpt 11/10/2005 18:59'!
add: item
	list add: item.
	self changed: #list! !

!PLMExample methodsFor: 'as yet unclassified' stamp: 'hpt 11/10/2005 19:00'!
asMorph
	| plm |
	plm _ PluggableListMorph
		on: self
		list: #list
		selected: #selectedItemIndex
		changeSelected: #selectedItemIndex:.
	^plm.
		! !

!PLMExample methodsFor: 'as yet unclassified' stamp: 'hpt 11/10/2005 19:00'!
initialize
	list _ OrderedCollection with: 'uno' with: 'dos' with: 'tres'.
	selectedItemIndex _ 1! !

!PLMExample methodsFor: 'as yet unclassified' stamp: 'hpt 11/10/2005 18:58'!
list
	^list! !

!PLMExample methodsFor: 'as yet unclassified' stamp: 'hpt 11/10/2005 19:03'!
removeSelected
	((self selectedItemIndex > 0) & (self selectedItemIndex < self list size))
		ifTrue: [list removeAt: self selectedItemIndex].
	self selectedItemIndex: 0.
	self changed: #list.! !

!PLMExample methodsFor: 'as yet unclassified' stamp: 'hpt 11/10/2005 19:00'!
selectedItemIndex
	^selectedItemIndex! !

!PLMExample methodsFor: 'as yet unclassified' stamp: 'hpt 11/10/2005 19:01'!
selectedItemIndex: anIndex
	selectedItemIndex _ anIndex.
	self changed: #selectedItemIndex.! !


More information about the Squeak-dev mailing list