I'm not familiar with Spec but I'll have a go...

On Wed, 17 Jul 2019 at 07:03, Steve Quezadas <steve...@gmail.com> wrote:

> On Tue, Jul 16, 2019 at 7:43 AM Ben Coman <b...@openinworld.com> wrote:
>>
>> On Tue, 16 Jul 2019 at 12:49, Steve Quezadas <steve...@gmail.com> wrote:
>> >
>> > I am running through the "Spec UI Framework" tutorial, and in it has a 
>> > widget class inherited from "ComposablePresenter" (ComposablePresenter 
>> > subclass: #WidgetClassList). But for some reason the 
>> > "whenSelectedItemChanged:" method call does not execute when I select any 
>> > item on the GUI list. Is there anything I'm missing?
>> >
>> > I posted this earlier on the list, and someone suggested I try  
>> > "whenActivatedDo:" or "whenSelectionChangedDo:", but it doesn't do 
>> > anything as well. The code looks like this:
>> >
>> > whenSelectedItemChanged: aBlock
>> >     Transcript show: 'should get here; cr.
>> >
>> > I am using Pharo 7.
>>
>> Can you FileOut the entire sample class and attached it?
>>
>> cheers -ben
>>
>
> Ok, I filed out and it exported the file 'WidgetClassList.st' . This is the 
> contents of the file:
>
> 'From Pharo7.0.3 of 12 April 2019 [Build information: 
> Pharo-7.0.3+build.158.sha.0903ade8a6c96633f07e0a7f1baa9a5d48cfdf55 (64 Bit)] 
> on 16 July 2019 at 3:58:28.785036 pm'!
> ComposablePresenter subclass: #WidgetClassList
> instanceVariableNames: 'list'
> classVariableNames: ''
> poolDictionaries: ''
> category: 'QuotesProg'!
>
> !WidgetClassList methodsFor: 'initialization' stamp: 'SteveQuezadas 7/10/2019 
> 14:07'!
> initializeWidgets
> list := self newList.
> list items: (AbstractWidgetPresenter allSubclasses
> sorted: [:a :b | a name < b name ]).
> self focusOrder add: list.! !
>
>
> !WidgetClassList methodsFor: 'events-shortcuts' stamp: 'SteveQuezadas 
> 7/15/2019 21:40'!
> whenSelectedItemChanged: aBlock
> Transcript show: 'got here'; cr.
> ! !

Looking at ListPresenter>>whenSelectedItemChanged: aBlock
it is registering aBlock on selectionHolder using #whenChangedDo:
Reviewing selectionHolder "Code search...>References to it" I see that
selectionHolder is initialized as an instance of SelectionHolderClass.

So it seems you are expecting whenSelectedItemChanged: to be called
every time the-selection-is-changed
when actually it is only called once (by your application) to register
the block-to-be-called when the-selection-is-changed.
You don't seem to have done any such registration.

cheers -ben

Reply via email to