Sometimes you really just want a set of buttons to act like a toggle
button bar. There's nothing dynamic about them. Putting them into an
container (I would recommend Group over Container since its much lighter
in weight and you probably don't need the possibility of scrolling).

The SingleSelectionContainerBead is what is looking at the children of the
Group and listening for their events and translating the clicks into:
state changes in the buttons (one highlighted, the others not) and
dispatching an event:

<js:SingleSelectionContainerBead change="changeHandler(event)" />

Its much like a controller with some model information (what's selected).
That's a pretty straightforward way to make this. The
SingleSelectionContainerBead could, if needed, programmatically select one
of the toggle buttons via index; don't know if that¹s a requirement you
have, but it would make the bead more useable to others.

The List, dataProvider, itemRenderers, factories, etc. is pretty complex
right now. I think we've seen a lot and maybe we should rethink all of
that. I'm trying to make additional beads that augment the lists to just
create and insert a single itemRenderer in response to a CollectionEvent
on ArrayList. Conceptually simple, but its just messy.

FWIW: if you aren't concerned about the SWF side, then don't even use a
layout, jut make a Group (which has no layout by default) and style the
toggle buttons with display style. Make the browser do the work and reduce
your download size.

‹peter

On 12/6/17, 3:40 AM, "Harbs" <[email protected]> wrote:

>>> 
>>> Agreed, but I can¹t think of a way to do this.
>> 
>> One way is to have assignable removeElement logic.
>
>Meaning an assignable Function property, or something else?
>
>> Another is to have a bead that overwrites
>>UIBase.prototype.removeElement.
>> What won't work on SWF but will on JS.
>
>Interesting. Probably worth looking into.
>
>>> 
>>> I¹m trying to keep this really simple. ButtonBar extends List which
>>> requires dataProviders, ItemRendererers, etc. My approach is to allow
>>> adding any component which has a selected property to any container.
>>>The
>>> bead will handle correcting the selection of the unselected elements. I
>>> want to enable the following mxml:
>>> 
>>> <js:HContainer>
>>>   <js:beads>
>>>       <js:SingleSelectionContainerBead/>
>>>   </js:beads>
>>>   <js:ToggleTextButton text="Fee"/>
>>>   <js:ToggleTextButton text="Fi"/>
>>>   <js:ToggleTextButton text="Fo"/>
>>>   <js:ToggleTextButton text="Fum"/>
>>> </js:HContainer>
>>> 
>>> Those ToggleTextButtons could be RadioButtons, Checkboxes, etc.
>> 
>> We should make sure it works, but I would expect issues around focus,
>> keyboard selection and accessibility.  And also, how it upgrades to
>>being
>> able to load the text labels from resources or a server and add or
>>remove
>> buttons.
>
>I¹m not sure I understand why you think these are issues. The components
>should be pretty much self contained. I guess I¹ll see.
>
>> This sort of thing makes me wonder if there is some other item renderer
>> contract we should be offering instead.  IIRC, right now, the contract
>> dictates that the renderer must have a "data" property.  Maybe if there
>> was a contract where we could dictate the property to set you could just
>> drop in an existing component as a renderer.  There was a similar thing
>>in
>> Flex.  It was a bit heavy, but maybe folks don't care.
>> 
>> Way back I pointed out that all components should be able to be
>>expressed
>> as a UIBase or ContainerBase/GroupBase with a collection of beads.  It
>> would be interesting to see what the other List beads expect.  Right
>>now a
>> factory watches a dataProvider and generates an item renderer for each
>> dataProvider item.  Hopefully the other beads don't care how the item
>> renderers appeared and can be repurposed to your pattern.  IOW, either
>>you
>> specify a factory and an item renderer and a dataProvider or you supply
>>a
>> set of children, but everything else should work.
>
>I¹m not sure if I¹m following you here. My understanding was that the
>only way to specify the children of a list is to provide a dataProvider.
>It seems like you are saying that it should technically be possible to
>add the children directly. For kicks I just tried the following to see
>and it did not work at all (i.e. nothing was added to the button bar):
><js:ButtonBar>
>       <js:ToggleTextButton text="Fee"/>
>       <js:ToggleTextButton text="Fi"/>
>       <js:ToggleTextButton text="Fo"/>
>       <js:ToggleTextButton text="Fum"/>
></js:ButtonBar>
>
>I¹m guessing that you are suggesting a factory could be added with
>conditional logic.
>
>Harbs
>
>

Reply via email to