Setting the column width on a FxTextArea control in Flex Gumbo

by Peter deHaan on November 23, 2008

in FxTextArea, beta

The following example shows how you can set the column width on a Flex Gumbo FxTextArea control by setting the columnWidth style.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/11/23/setting-the-column-width-on-a-fxtextarea-control-in-flex-gumbo/ -->
<Application name="FxTextArea_columnWidth_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <ApplicationControlBar dock="true">
        <Form styleName="plain">
            <FormItem label="columnWidth:">
                <HSlider id="slider"
                        minimum="100"
                        maximum="300"
                        value="200"
                        snapInterval="1"
                        tickInterval="10"
                        liveDragging="true" />
            </FormItem>
        </Form>
    </ApplicationControlBar>

    <FxTextArea id="textArea"
            columnWidth="{slider.value}"
            columnCount="2"
            columnGap="20"
            textAlign="justify"
            width="100%">
        <content>
            <String source="data/lorem.html" />
        </content>
    </FxTextArea>

</Application>

View source is enabled in the following example.

You can also set the columnWidth style in an external .CSS file or <Style /> block, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/11/23/setting-the-column-width-on-a-fxtextarea-control-in-flex-gumbo/ -->
<Application name="FxTextArea_columnWidth_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <Style>
        FxTextArea {
            columnWidth: 300;
            columnCount: 2;
            columnGap: 20;
            textAlign: "justify";
        }
    </Style>

    <FxTextArea id="textArea"
            width="100%">
        <content>
            <String source="data/lorem.html" />
        </content>
    </FxTextArea>

</Application>

Or, you can set the columnWidth style using ActionScript, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/11/23/setting-the-column-width-on-a-fxtextarea-control-in-flex-gumbo/ -->
<Application name="FxTextArea_columnWidth_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <Script>
        <![CDATA[
            import mx.events.SliderEvent;

            private function slider_change(evt:SliderEvent):void {
                textArea.setStyle("columnWidth", evt.value);
            }
        ]]>
    </Script>

    <ApplicationControlBar dock="true">
        <Form styleName="plain">
            <FormItem label="columnWidth:">
                <HSlider id="slider"
                        minimum="100"
                        maximum="300"
                        value="200"
                        snapInterval="1"
                        tickInterval="10"
                        liveDragging="true"
                        change="slider_change(event);" />
            </FormItem>
        </Form>
    </ApplicationControlBar>

    <FxTextArea id="textArea"
            columnWidth="200"
            columnCount="2"
            columnGap="20"
            textAlign="justify"
            width="100%">
        <content>
            <String source="data/lorem.html" />
        </content>
    </FxTextArea>

</Application>

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: