• FLEX光标定位和插入文本


    因为目前的FLEX的RichTextEditor不支持图文混编,所以,只能自己动手了,实现最核心的部分,光标定位插入文本。

    MXML代码
    1. <?xml version="1.0" encoding="utf-8"?gt;   
    2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"gt;   
    3.  <mx:Script>  
    4.   <![CDATA[  
    5.      
    6.    [Bindable]  
    7.    private var textAreaString:String = "textAreaString";  
    8.    [Bindable]  
    9.    private var insertString:String = "|insert|";  
    10.      
    11.    private function insertHandler():void {  
    12.     if (textArea.selectionBeginIndex == textArea.selectionEndIndex) {  
    13.      var startPart:String = textAreaString.substring(0,textArea.selectionBeginIndex);  
    14.      var endPart:String = textAreaString.substring(textArea.selectionEndIndex,textAreaString.length);  
    15.      startPart+=insertString;  
    16.      startPart+=endPart;  
    17.      textAreaString = startPart;  
    18.     }  
    19.    }  
    20.      
    21.    private function changeInsertHandler():void {  
    22.     insertString = insertInput.text;  
    23.    }  
    24.   ]]>  
    25.  </mx:Script>  
    26.  <mx:TextArea id="textArea" x="10" y="21" width="298" height="158" text="{textAreaString}"/gt;   
    27.  <mx:Button x="316" y="20" label="Insert" click="insertHandler();"/gt;   
    28.  <mx:TextInput id="insertInput" x="316" y="50" text="{insertString}" change="changeInsertHandler();"/gt;   
    29. </mx:Application>  
    30.   
  • 相关阅读:
    Xcode 统计代码行数
    AWS 根用户MFA丢失后如何处理
    istio 基础入门
    AWS 如何挑选合适EC2实例类型
    word去除页眉首页横线
    word 题注 图注 表注 交叉引用 自动编号
    (转)Python基础热图-参数超级详解
    VScode 运行代码显示:Code is already running!
    pyside2安装避坑
    vscode import numpy error:DLL load failed: The specific module could not be found
  • 原文地址:https://www.cnblogs.com/zack/p/1434454.html
Copyright © 2020-2023  润新知