Do not allow editing in a separate area in a text area in Flex

I just want to prevent editing in some area of ​​the text area in flex. How can I do that?

let the length of the text in the text area be 50 characters, I want to allow editing if the cursor position is less than 15, and if the cursor position in the text area is more than 15, it should not allow the user to add more text to the text area, If the user presses any key, he should not add a character to the text area.

I used

event.preventDefault();
event.stopImmediatePropagation();
event.stopPropagation();

but it did not work for me.

Can anyone help me? Thank.

0
source share
1 answer

, . , , :

<fx:Script>
    <![CDATA[
        import spark.events.TextOperationEvent;

        protected function textarea1_changeHandler(event:TextOperationEvent):void
        {
            trace("indexchange: ",ta.selectionActivePosition);
        }

        protected function ta_changingHandler(event:TextOperationEvent):void
        {
            trace("indexchanging: ",ta.selectionActivePosition);
            if(ta.selectionActivePosition>15) event.preventDefault();
        }

    ]]>
</fx:Script>
<s:TextArea id="ta" x="6" y="11" width="420" text="12345678901234567890" changing="ta_changingHandler(event)" change="textarea1_changeHandler(event)"/>
0

Source: https://habr.com/ru/post/1779386/


All Articles