Hi, Thanks, I think i can do it if i take inspiration from your code. I will put too an anotation in the book to correct it. Marion, Le 20/05/2016 00:42, Peter Uhnák a écrit :
Hi,
I've made a simple example â see attached fileout.
Couple things to note:
1.
If i put it on instance side, the lookup don't find it (in the book Building UI with Spec, it said the lookup begin by the instance side and it allow to have specific UI, in part about layout)
As far as I know / as far as I can tell this is false for ComposableModel. For DynamicComposableModel you can override the method "#layout".
2. For some odd reason when you add a new radio button it looks like a checkbox and only once you click on it it turns into a checkbox⦠which is WTF but it shouldn't matter atm
3. DynamicComposableModel holds the item in a Dictionary, since you can't provide accessors for each item, you have to cobble together some other selector, as shown in createWidgets
4. I don't know if this is the best approach, but I've been using something like this for quite a while
I'm quite busy this week, however I scheduled to take a look at the Spec book next week as I should probably write something there⦠So if you have any more questions/comments please ask.
Peter
On Wed, May 18, 2016 at 2:19 PM, Marion Noirbent < ms.noirbent@etudiant.univ-lille1.fr> wrote:
Ok, I wait your answer. Thanks for your help. Marion,
Le 18/05/2016 12:04, Peter Uhnák a écrit :
Yes but someone must call rebuildWidget⦠I will try to take a look at this today and give a better/more comprehensive example.
Peter
On Wed, May 18, 2016 at 1:01 PM, stepharo <stepharo@free.fr> wrote:
I do not get it.
I still think that the solution of peter is the one to implement
rebuildWidget self widgets removeAll. self createWidgets. self needFullRebuild: false. self buildWithSpecLayout: self dynamicLayout. self alignButtons
dynamicLayout | keys | keys := self widgets keys. ^ SpecLayout composed newColumn: [ :c | keys do: [ :key | c newRow: key height: self class buttonHeight ]. c newRow: [ :r | ] ]; yourself
Le 18/5/16 à 12:46, Marion Noirbent a écrit :
Because I would use "openWithSpec" to build only when the widget is ready,
but it call a method (with the good pragma) on the class side.
In the example i use i have add RadioButtonModel with addRadioButton: in the collection buttons, it's not empty but RadioButtonModel is a ComposableModel and layout: is define in the subclass DynamicComposableModel .
Le 18/05/2016 10:22, stepharo a écrit :
But why from the class side.
buttons ^ buttons
returns an empty collection
and
rebuildWidget self widgets removeAll. self createWidgets. self needFullRebuild: false. self buildWithSpecLayout: self dynamicLayout. self alignButtons
Le 18/5/16 à 11:31, Marion Noirbent a écrit :
I was trying to use it but i have still the problem to call the
instance method from the class side, so i call the buildWithSpecLayout: in the method to add buttons in the collection, it seems work but i have an "MessageNotUnderstood" RadioButton>>layout:
Le 18/05/2016 09:20, stepharo a écrit :
marion the solution is what peter proposes.
Stef
Le 18/5/16 à 11:14, Marion Noirbent a écrit :
In fact i was trying to modify RadioButtonGroup to turn it into a
widget, #buttons is not a widget but its collection of widget.
May you have confused RadioButtonGroup with the MenuModel / MenuGroupModel / MenuItemModel which are widgets. I take inspiration from them and I would got the same kind of behaviour.
Le 17/05/2016 21:11, stepharo a écrit :
Thanks Johan
We looked at
RadioButtonGroupExample
but you see we cannot have a RadioButtonGroupPresenter having 2, 3 or 4 radioButton.
Stef
Le 17/5/16 à 18:52, Johan Fabry a écrit :
Hi Marion,
the class side message of defaultSpec is generally meant to be used if you use a fixed number of widgets, so you can put the reference to the name of each widget there (in cour case #buttons). For variable number of widgets you should have a look at the dynamic features of Spec.
That being said, It looks like what you really want to use is a Radio Button Group. Have a look at RadioButtonGroupExample.
HTH
-- Does this mail seem too brief? Sorry for that, I donât mean to be rude! Please see http://emailcharter.org .
Johan Fabry - http://pleiad.cl/~jfabry PLEIAD and RyCh labs - Computer Science Department (DCC) - University of Chile
On May 17, 2016, at 13:48, Marion Noirbent
<ms.noirbent@etudiant.univ-lille1.fr> wrote:
Hi, I'm trying to create a widget whith Spec, managing a collection of RadioButton. But I have a problem with defaultSpec (the accessor of the collection is the methods "buttons") :
If i put defaultSpec on class side, i can't acces the collection of the instance. (the following code iterate on the string)
defaultSpec <spec: #default> ^ SpecLayout composed newColumn: [ :column | #buttons do: [ :item | column add: item ] ]; yourself
If i put it on instance side, the lookup don't find it (in the book Building UI with Spec, it said the lookup begin by the instance side and it allow to have specific UI, in part about layout)
defaultSpec <spec: #default> ^ SpecLayout composed newColumn: [ :column | self buttons do: [ :item | column add: item ] ]; yourself
Any idea ?
Marion Noirbent,
-- Ma clé publique sur pgp.mit.edu
-- Ma clé publique sur pgp.mit.edu