You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@royale.apache.org by Maria Jose Esteve <mj...@iest.com> on 2021/10/04 19:26:35 UTC

Jewel ComboBox/VirtualComboBox - ItemRenderer assignment by as3

Hello,
I'm testing with the VirtualComboBox, specifically I want to assign one itemrenderer or another, depending on the value of a property.
I have tried, without success:


- Add a className when setting the property:



In this case, I define the IItemRenderer inside a known CSS class:

.itemrenderertruncate{

  IItemRenderer: ClassReference("org.apache.royale.community.itemRenderers.LabelTruncateItemRenderer");

}



In control, itemRendererTruncateByDefault property:



        private var _itemRendererTruncateByDefault:Boolean=false;

        public function set itemRendererTruncateByDefault(value:Boolean):void

        {

            _itemRendererTruncateByDefault = value;

            // The pseudo-class css itemrenderertruncate has the IItemRenderer assigned to it.

            // It adds the css selector but does not recognise the IItemRenderer assigned by ClassReference.

            if(value)

                addClass('itemrenderertruncate');

        }



-          Set the as3 class directly (I override loadBeads to set it before the IBeadView loads)


        override protected function loadBeads():void
        {
            // We must assign the itemRenderer to the control before loading the IBeadView bead.
            // At first it assigns the correct itemRenderer, but then it does not recognise it and sets the default itemRenderer, why?
            // (After this instruction, it has been verified that the itemRenderer is never set again).
            if(_itemRendererTruncateByDefault)
            {
                itemRenderer = new ClassFactory(LabelTruncateItemRenderer);
                // Test: is ok --> var it:Object = itemRenderer.newInstance();  it is LabelTruncateItemRenderer
            }
            super.loadBeads();
        }

What am I doing wrong?

Thx
Hiedra

RE: Jewel ComboBox/VirtualComboBox - ItemRenderer assignment by as3

Posted by Maria Jose Esteve <mj...@iest.com>.
Solved.
The problem is not the itemRenderer but my modification of yesterday [1]. I modified it, as I said in the PR comments, and the list no longer loses the itemRenderer. Actually, it's not that I lost the itemRenderer but that the creation and assignment was not effective.

[1] https://github.com/apache/royale-asjs/pull/1153

Hiedra.

De: Maria Jose Esteve <mj...@iest.com>
Enviado el: lunes, 4 de octubre de 2021 21:27
Para: users@royale.apache.org
Asunto: Jewel ComboBox/VirtualComboBox - ItemRenderer assignment by as3

Hello,
I'm testing with the VirtualComboBox, specifically I want to assign one itemrenderer or another, depending on the value of a property.
I have tried, without success:


- Add a className when setting the property:



In this case, I define the IItemRenderer inside a known CSS class:

.itemrenderertruncate{

  IItemRenderer: ClassReference("org.apache.royale.community.itemRenderers.LabelTruncateItemRenderer");

}



In control, itemRendererTruncateByDefault property:



        private var _itemRendererTruncateByDefault:Boolean=false;

        public function set itemRendererTruncateByDefault(value:Boolean):void

        {

            _itemRendererTruncateByDefault = value;

            // The pseudo-class css itemrenderertruncate has the IItemRenderer assigned to it.

            // It adds the css selector but does not recognise the IItemRenderer assigned by ClassReference.

            if(value)

                addClass('itemrenderertruncate');

        }



-          Set the as3 class directly (I override loadBeads to set it before the IBeadView loads)


        override protected function loadBeads():void
        {
            // We must assign the itemRenderer to the control before loading the IBeadView bead.
            // At first it assigns the correct itemRenderer, but then it does not recognise it and sets the default itemRenderer, why?
            // (After this instruction, it has been verified that the itemRenderer is never set again).
            if(_itemRendererTruncateByDefault)
            {
                itemRenderer = new ClassFactory(LabelTruncateItemRenderer);
                // Test: is ok --> var it:Object = itemRenderer.newInstance();  it is LabelTruncateItemRenderer
            }
            super.loadBeads();
        }

What am I doing wrong?

Thx
Hiedra