Hi Maria Jose,

what surprises me is your model is not IJewelSelectionModel. Since is a
jewel component you need it to make it work.
So I think the approach is to add it to your code. If you don't want to add
it I need to know the reason to understand it.



El mié, 2 dic 2020 a las 3:21, Maria Jose Esteve (<[email protected]>)
escribió:

> Hi, Carlos
> Some time ago I implemented a control that ran from Jewel ToggleButtonBar,
> PagNavigationButtonBar, and today we realized that it has stopped working.
> The console shows an error in
>
> The problem occurs because the ToggleButtonBar loads the
> ListSingleSelectionMouseController and ButtonBarModel beads, and the latter
> does not implement IJewelSelectionModel and does not have the new
> isItemClicked property.
>
> A possible solution would be to modify the selectedHandler function (no
> other control would give an error):
>
> override protected function selectedHandler(event:ItemClickedEvent):void
> {
>         if(listModel is IJewelSelectionModel)
>                 (listModel as IJewelSelectionModel).isItemClicked = true;
>         super.selectedHandler(event);
>                if(listModel is IJewelSelectionModel)
>                 (listModel as IJewelSelectionModel).isItemClicked = false;
> }
>
> I have tested it and it works fine. What do you think?
>
> Thx.
> Hiedra.
>
> -----Mensaje original-----
> De: Carlos Rovira <[email protected]>
> Enviado el: lunes, 30 de noviembre de 2020 9:09
> Para: Apache Royale Development <[email protected]>
> Asunto: Re: Jewel List - selectionChange (Bis)
>
> ok, let me know how it goes
> thanks
>
> El lun, 30 nov 2020 a las 1:37, Maria Jose Esteve (<[email protected]>)
> escribió:
>
> > Hi Carlos,
> > Yes, I have seen your changes and was comparing them with mine. In the
> > end, I also modified the controller and the model but in another way.
> > I have to analyze your solution 😝, because I added some extra
> > modifications that may not be necessary now.
> > Just this past week I was implementing an extension to the Jewel
> > ComboBox control and had problems with the popup list, I am also going
> > to check these modifications to see if they have been fixed.
> >
> > Thanks Carlos, I'll tell you.
> > Hiedra.
> >
> > -----Mensaje original-----
> > De: Carlos Rovira <[email protected]> Enviado el: domingo, 29 de
> > noviembre de 2020 22:59
> > Para: Apache Royale Development <[email protected]>
> > Asunto: Re: Jewel List - selectionChange (Bis)
> >
> > Hi Maria Jose,
> >
> > I finally was able to have time to check this. I finally think this is
> > very close to the List component since always users will want to put
> > the selectedItem into view (can't think of a case that will not be
> > what we all want). So I abandoned the bead idea. Instead I made the
> > scrollToIndex run in any case selectionChange is triggered but left
> > out the case when the user clicks over an item, since as you said
> > don't this a case we want since the item is already on view.
> >
> > Hope this helps and I think we can close this case
> >
> > Carlos
> >
> >
> >
> > El jue, 5 nov 2020 a las 0:51, Maria Jose Esteve (<[email protected]>)
> > escribió:
> >
> > > Hi,
> > > This could be a possible implementation of the
> > > ScrollIndexToSelection
> > bead:
> > >
> > > package xxxx.jewel.beads.controls.list {
> > >         import org.apache.royale.core.IBead;
> > >         import org.apache.royale.core.IStrand;
> > >         import org.apache.royale.events.Event;
> > >         import org.apache.royale.events.IEventDispatcher;
> > >         import org.apache.royale.jewel.beads.views.IScrollToIndexView;
> > >         import org.apache.royale.core.ISelectionModel;
> > >         import org.apache.royale.core.UIBase;
> > >
> > >         /**
> > >          *  The ScrollIndexToSelection bead is a specialty bead that
> > > can be used with
> > >          *  Jewel List List control to make sure that whenever the
> > > selected item changes it becomes visible.
> > >          *
> > >          *  @langversion 3.0
> > >          *  @playerversion Flash 10.2
> > >          *  @playerversion AIR 2.6
> > >          *  @productversion Royale 0.9.8
> > >          */
> > >         public class ScrollIndexToSelection implements IBead
> > >         {
> > >                 /**
> > >                  *  constructor.
> > >                  *
> > >                  *  @langversion 3.0
> > >                  *  @playerversion Flash 10.2
> > >                  *  @playerversion AIR 2.6
> > >                  *  @productversion Royale 0.9.8
> > >                  */
> > >                 public function ScrollIndexToSelection()
> > >                 {
> > >                 }
> > >
> > >                 protected var _strand:IStrand;
> > >
> > >                 /**
> > >                  *  @copy org.apache.royale.core.IBead#strand
> > >                  *
> > >                  *  @langversion 3.0
> > >                  *  @playerversion Flash 10.2
> > >                  *  @playerversion AIR 2.6
> > >                  *  @productversion Royale 0.9.8
> > >                  */
> > >                 public function set strand(value:IStrand):void
> > >                 {
> > >                         _strand = value;
> > >
> > > IEventDispatcher(_strand).addEventListener("selectionChanged",
> > > selectionChangeHandler);
> > >                 }
> > >
> > >                 /**
> > >                  *  Ensures that the data provider item at the given
> > > index is visible.
> > >                  */
> > >                         private function
> > > selectionChangeHandler(ev:Event):void
> > >                 {
> > >                         var host:UIBase = UIBase(_strand);
> > >                         if(!host)
> > >                                 return;
> > >
> > >                         if(host.view && host.view is
> IScrollToIndexView)
> > >                         {
> > >                                 if(host.model && host.model is
> > > ISelectionModel)
> > >                                 {
> > >                                         var setIndex:int =
> > > (host.model as ISelectionModel).selectedIndex;
> > >                                         (host.view as
> > > IScrollToIndexView).scrollToIndex(setIndex);
> > >
> > >                                 }
> > >                         }
> > >                  }
> > >         }
> > > }
> > >
> > > The bead works, but the user experience is bad, too many jumps /
> > > scrolls ...
> > > They say that ignorance is very daring, you have to forgive me 😝 ...
> > > this is how I see it:
> > > The selectionChanged event of the List is dispatched when the
> > > selectedIndex of the model is explicitly set and this occurs in at
> > > least 3
> > > scenarios:
> > > 1- Assignment by code, valueCommit
> > > 2- Click on an itemRenderer
> > > 3- And when we move with the keyboard (key down / up) Of these three
> > > scenarios I think that the only one that should be controlled is 1,
> > > why? Because when clicked, the item is visible and, when we move
> > > with the keyboard the ListKeyDownController, after modifying the
> > > selectedIndex, explicitly calls scrollToIndex. Could scenario 1,
> > > valueCommit, be differentiated from the rest?
> > >
> > > If the double positioning that occurs in scenarios 2 and 3 could not
> > > be avoided, we could "hide" it by overriding the scrollToIndex
> > > function so that it does not make the scroll change if the item is
> > > visible at that moment.
> > >
> > > As you see?
> > >
> > > Thx.
> > > Hiedra
> > >
> > > -----Mensaje original-----
> > > De: Carlos Rovira <[email protected]> Enviado el: miércoles, 4
> > > de noviembre de 2020 11:16
> > > Para: Apache Royale Development <[email protected]>
> > > Asunto: Re: Jewel List - selectionChange (Bis)
> > >
> > > Yeah, I think it should be pretty straight forward.
> > > For example a name could be "ScrollIndexToSelection" in the "
> > > org.apache.royale.jewel.beads.controls.list" package.
> > > Then it just listen for selectionChange event and do the
> > > scrollToIndex
> > >
> > > thanks!
> > >
> > > El mié., 4 nov. 2020 a las 10:40, Maria Jose Esteve
> > > (<[email protected]>)
> > > escribió:
> > >
> > > > Right Carlos. If the guideline is that the operation should be the
> > > > same, basically, I also think it should be a bead, since the
> > > > application of the scrollToIndex, whenever the selected element is
> > > > changed, it would be a sudden change.
> > > >
> > > >
> > > >
> > > > Would we agree to add this functionality in a bead?
> > > >
> > > > If you tell me yes, I try 😝
> > > >
> > > >
> > > >
> > > > Thx.
> > > >
> > > > Hiedra
> > > >
> > > > -----Mensaje original-----
> > > > De: Carlos Rovira <[email protected]> Enviado el: miércoles,
> > > > 4 de noviembre de 2020 10:02
> > > > Para: Apache Royale Development <[email protected]>
> > > > Asunto: Re: Jewel List - selectionChange (Bis)
> > > >
> > > >
> > > >
> > > > Hi Maria Jose,
> > > >
> > > >
> > > >
> > > > so if I'm understanding correctly, we currently have the same
> > > > behaviour as Flex (maybe we need to update a bit to improve over
> > > > time, but in essence is the same): Moving with keys trigger the
> > > > scrollToIndex, but if we use programmatically selectedItem, the
> > > scrollToIndex is not triggered, right?
> > > >
> > > >
> > > >
> > > > If so I think we are ok in the TLC List, and the behaviour should
> > > > go to a bead.
> > > >
> > > >
> > > >
> > > > Can you confirm?
> > > >
> > > >
> > > >
> > > > thanks
> > > >
> > >
> > >
> > > --
> > > Carlos Rovira
> > > Apache Member & Apache Royale PMC
> > > *Apache Software Foundation*
> > > http://about.me/carlosrovira
> > >
> >
> >
> > --
> > Carlos Rovira
> > Apache Member & Apache Royale PMC
> > *Apache Software Foundation*
> > http://about.me/carlosrovira
> >
>
>
> --
> Carlos Rovira
> Apache Member & Apache Royale PMC
> *Apache Software Foundation*
> http://about.me/carlosrovira
>


-- 
Carlos Rovira
Apache Member & Apache Royale PMC
*Apache Software Foundation*
http://about.me/carlosrovira

Reply via email to