Measuring from of Label with padding strange/incorrect

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Measuring from of Label with padding strange/incorrect

chris_flex
Hi,

I have an itemrenderer based on a group with a label inside. If there is text which would exactly fit in one line and I have a padding in the label, the label is displayed in two lines but the measured value is at is is one line...

Is this a bug or am I doing something wrong?

Kind regards

Christian
Reply | Threaded
Open this post in threaded view
|

Re: Measuring from of Label with padding strange/incorrect

Olaf Krueger
chris_d_k wrote
Hi,

I have an itemrenderer based on a group with a label inside. If there is text which would exactly fit in one line and I have a padding in the label, the label is displayed in two lines but the measured value is at is is one line...

Is this a bug or am I doing something wrong?

Kind regards

Christian
Don't know the reason for this but did you tried the spark label properties "maxDisplayedLines" and "lineBreak".

HTH,
Olaf
Reply | Threaded
Open this post in threaded view
|

Seems to be a bug...

chris_flex
Here a test Project:

<?xml version="1.0"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" >
    <fx:Script>
<![CDATA[
        import mx.collections.ArrayCollection;

        private var dataD:ArrayCollection = new ArrayCollection(["Das ist ein Test!", "Das ist ein Test! i", "Das ist ein Test! ii", "Das ist ein Test! iii"]);

        ]]>
</fx:Script>
    <s:List dataProvider="{dataD}" itemRenderer="TestItemRenderer" >
        <s:layout>
            <s:VerticalLayout gap="10"/>
        </s:layout>
    </s:List>
</s:View>

<?xml version="1.0"?>
<s:Group width="115" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" implements="mx.core.IDataRenderer, spark.components.IItemRenderer">
    <fx:Style>

        @font-face {
            src:url("assets/arial.ttf");
            fontFamily: myFontFamily;
            embedAsCFF: true;
        }

    </fx:Style>

        <s:Rect left="0" right="0" top="0" bottom="0" radiusX="5" radiusY="5">
            <s:fill>
                <s:SolidColor color="0xFF0000"/>
            </s:fill>
        </s:Rect>
        <s:Label id="labelComp" maxWidth="115" paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10" fontSize="12" fontFamily="myFontFamily"/>
    <fx:Script>
<![CDATA[
        public function get data():Object
        {
            return _data;
        }

        private var _data:Object;
        public function set data(value:Object):void
        {
            _data = value;
            labelComp.text = value as String;
        }

        public function get itemIndex():int
        {
            return 0;
        }

        public function set itemIndex(value:int):void
        {
        }

        public function get dragging():Boolean
        {
            return false;
        }

        public function set dragging(value:Boolean):void
        {
        }

        public function get label():String
        {
            return "";
        }

        public function set label(value:String):void
        {
        }

        public function get selected():Boolean
        {
            return false;
        }

        public function set selected(value:Boolean):void
        {
        }

        public function get showsCaret():Boolean
        {
            return false;
        }

        public function set showsCaret(value:Boolean):void
        {
        }
        ]]>
</fx:Script>
</s:Group>

as long as the labelComp has a maxWidth=115 it is broken... having width=115 everything is fine...