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. - Steve |
On Tue, 16 Jul 2019 at 12:49, Steve Quezadas <[hidden email]> 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 |
Steve
How did you get the source code for the examples? Pages 12-13 of the "Spec UI Framework" booklet give the code for the methods of class WidgetClassList, and there we find: WidgetClassList >> whenSelectedItemChanged: aBlock list whenSelectedItemChanged: aBlock This looks very much like the 'when....' methods of all the other subclasses of ComposablePresenter. It should at least do something when activated. HTH Peter Kenny -----Original Message----- From: Pharo-users <[hidden email]> On Behalf Of Ben Coman Sent: 16 July 2019 15:42 To: Any question about pharo is welcome <[hidden email]> Subject: Re: [Pharo-users] "whenSelectedItemChanged:" in Spec On Tue, 16 Jul 2019 at 12:49, Steve Quezadas <[hidden email]> 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 |
In reply to this post by Ben Coman
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. ! ! !WidgetClassList methodsFor: 'api' stamp: 'SteveQuezadas 6/26/2019 18:22'! title ^ 'Widgets'! ! !WidgetClassList methodsFor: 'api' stamp: 'SteveQuezadas 7/15/2019 19:09'! list ^ list.! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! WidgetClassList class instanceVariableNames: ''! !WidgetClassList class methodsFor: 'specs' stamp: 'SteveQuezadas 7/10/2019 14:14'! defaultSpec ^ SpecLayout composed add: #list; yourself! ! On Tue, Jul 16, 2019 at 7:43 AM Ben Coman <[hidden email]> wrote: On Tue, 16 Jul 2019 at 12:49, Steve Quezadas <[hidden email]> wrote: |
I'm not familiar with Spec but I'll have a go...
On Wed, 17 Jul 2019 at 07:03, Steve Quezadas <[hidden email]> wrote: > On Tue, Jul 16, 2019 at 7:43 AM Ben Coman <[hidden email]> wrote: >> >> On Tue, 16 Jul 2019 at 12:49, Steve Quezadas <[hidden email]> 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 |
Ben Coman wrote
> I'm not familiar with Spec but I'll have a go... > > On Wed, 17 Jul 2019 at 07:03, Steve Quezadas < > steveeq1@ > > wrote: > >> On Tue, Jul 16, 2019 at 7:43 AM Ben Coman < > btc@ > > wrote: >>> >>> On Tue, 16 Jul 2019 at 12:49, Steve Quezadas < > steveeq1@ > > 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 Essentially ben is right. The method WidgetClassList >> when SelectedItemChanged: should just relay the message to the component ListPresenter, in the instvar list, which will carry out the registration as he describes. The problem is that this method seems to have been replaced by a debugging method, which simply displays a progress message on the Transcript. I think all you need is to enter the correct code for this method as shown in the 'Spec UI Framework' booklet: WidgetClassList >> whenSelectedItemChanged: aBlock list whenSelectedItemChanged: aBlock This is at least worth a try. You will be sticking to the code as shown in the booklet. HTH Peter Kenny -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html |
In reply to this post by Ben Coman
Oh, I see. Ok, I am somewhat new to pharo smalltalk so I'm getting used to the paradigm. Thank you. The best way to learn is to "do". I can learn a lot by trying to figure out ways around unexpected behavior. On Tue, Jul 16, 2019 at 5:39 PM Ben Coman <[hidden email]> wrote: I'm not familiar with Spec but I'll have a go... |
Free forum by Nabble | Edit this page |