If you decide to use this example for the Spec chapter I could do another pass on the code and make it nicer.
Andrei On Tue, Jul 9, 2013 at 9:11 AM, Stéphane Ducasse <stephane.duca...@inria.fr>wrote: > Ben > > I'm still fuzzy after a flood in the flat we rent at 2 in the morning :) > but I was thinking that may be we can use this example to explain the > dynamic part of spec. > So can you take this view also when you look at the code? > If this sounds good to you, I will put on the stack that I should look and > see how to put it in the Spec chapter. > > Stef > > On Jul 8, 2013, at 11:05 PM, Andrei Vasile Chis < > chisvasileand...@gmail.com> wrote: > > Hi, > > I've implemented a small UI using the dynamic features of spec and I'd > like to know if there isn't a better way to do it. My use case is simple: I > have a normal ComposableModel that has two models - a list and > a DynamicComposableModel. The DynamicComposableModel should contain a list > of buttons that should change every time the user selects an element in the > list. I've implemented a demo that can be seen if you download the package > DynamicSpec-Examples from > http://www.smalltalkhub.com/mc/AndreiChis/Playground/main and execute the > code from the class comment of DSChangingButtons. > > My problem is that the widget containing the buttons has to define a spec > layout on the class side. I haven't found a way to tell the spec layout to > add a widget and use a method on the object for constructing the layout. > I've manage to get away by dynamically reconstructing the layout when the > selection changes, however it's not that nice because I had to duplicate > the layout of the main widget both on the class side and the object side. > It would be nice to add a widget to the layout like this: 'aSpec > dynamicAdd: modelGetter withSpec: aSymbol ' that would call aSymbol on the > object and not on the class. This may or may not make sense :) > > To be concrete, the method DSToolbarModel>>updateButtons will call the > method dynamicLayout on it's parent which in turn will > call dynamicLayoutWithSpec: on the toolbar. I'd like to avoid this, and > when specifying the layout of the parent widget to call a method on the > instance side of it subwidgets to get their layout. > > Now I'll end here this rather long email :) > > Cheers, > Andrei > > >