首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

顺利,附源码 flex cursor textarea 光标 位置 插入 insert caret

2012-11-07 
成功,附源码 flex cursor textarea 光标 位置 插入 insert caretprivate function onConsumeSmsParamClick

成功,附源码 flex cursor textarea 光标 位置 插入 insert caret

private function onConsumeSmsParamClicked(e:MouseEvent):void{this.consumeSmsTemplate.str = e.target.text;this.consumeSmsTemplate.focusManager.setFocus(this.consumeSmsTemplate);}

?

<mx:HBox verticalAlign="bottom"><trade:TextAreaExt id ="prepaySmsTemplate"   styleName="input01" width="400" height="80" backgroundColor="#ffffff"/><mx:Button label="预览内容" id="prepaySmsPreview" height="20" fontSize="12" fontWeight="normal"/></mx:HBox>
???????<mx:HBox horizontalGap="0" id="prepaySmsParam" fontSize="12" fontWeight="normal">????????<mx:Label text="动态参数:"/>????????<mx:VBox verticalGap="0">??? ???????? ??<mx:HBox horizontalGap="3">???????? ???<mx:Text text="会员姓名" styleName="lan" textDecoration="underline" fontWeight="normal" id="canshu11" mouseOver="canshu11.setStyle('textDecoration',null);" mouseOut="canshu11.setStyle('textDecoration','underline');" buttonMode="true" useHandCursor="true" mouseChildren="false"/>???????? ???<mx:Text text="卡号后四位" styleName="lan" textDecoration="underline" fontWeight="normal" id="canshu12" mouseOver="canshu12.setStyle('textDecoration',null);" mouseOut="canshu12.setStyle('textDecoration','underline');" buttonMode="true" useHandCursor="true" mouseChildren="false"/>???????? ???<mx:Text text="充值时间" styleName="lan" textDecoration="underline" fontWeight="normal" id="canshu13" mouseOver="canshu13.setStyle('textDecoration',null);" mouseOut="canshu13.setStyle('textDecoration','underline');" buttonMode="true" useHandCursor="true" mouseChildren="false"/>???????? ???<mx:Text text="充值金额" styleName="lan" textDecoration="underline" fontWeight="normal" id="canshu15" mouseOver="canshu15.setStyle('textDecoration',null);" mouseOut="canshu15.setStyle('textDecoration','underline');" buttonMode="true" useHandCursor="true" mouseChildren="false"/>???????? ??</mx:HBox>?????????? ?<mx:HBox horizontalGap="3">???????? ???<mx:Text text="预存余额" styleName="lan" textDecoration="underline" fontWeight="normal" id="canshu16" mouseOver="canshu16.setStyle('textDecoration',null);" mouseOut="canshu16.setStyle('textDecoration','underline');" buttonMode="true" useHandCursor="true" mouseChildren="false"/>?????????? ??<mx:Text text="积分剩余数量" styleName="lan" textDecoration="underline" fontWeight="normal" id="canshu18" mouseOver="canshu18.setStyle('textDecoration',null);" mouseOut="canshu18.setStyle('textDecoration','underline');" buttonMode="true" useHandCursor="true" mouseChildren="false"/>?????????? ??<mx:Text text="优惠券剩余数量" styleName="lan" textDecoration="underline" fontWeight="normal" id="canshu19" mouseOver="canshu19.setStyle('textDecoration',null);" mouseOut="canshu19.setStyle('textDecoration','underline');" buttonMode="true" useHandCursor="true" mouseChildren="false"/>?????????? ??<mx:Text text="商户简称" styleName="lan" textDecoration="underline" fontWeight="normal" id="canshu20" mouseOver="canshu20.setStyle('textDecoration',null);" mouseOut="canshu20.setStyle('textDecoration','underline');" buttonMode="true" useHandCursor="true" mouseChildren="false"/>?????????? ?</mx:HBox>?? ??????? ?</mx:VBox>?????? ?</mx:HBox>
?this.prepaySmsParam.addEventListener(MouseEvent.CLICK,onPrepaySmsParamClicked);??? ??

??

package com.tongcard.tcc.main.view.deskBack.sysManage.config.trade{import flash.events.Event;import flash.events.FocusEvent;import mx.controls.TextArea;public class TextAreaExt extends TextArea { public var insertText:String = '';public function TextAreaExt(){super(); this.addEventListener(FocusEvent.FOCUS_IN,onFocusIn);}private function onFocusIn(e:Event):void{trace(this.textField.caretIndex); this.textField.replaceText(this.textField.caretIndex,this.textField.caretIndex,insertText);this.insertText = '';}}}

?

?

?

?

?

?

?

?

var insertIndex:int = tf.getCharIndexAtPoint( tf.mouseX, tf.mouseY );
tf.replaceText( insertIndex, insertIndex, "Here is some more text" );
啊哈,

http://www.flexdeveloper.eu/forums/flex-builder-flash-builder-eclipse/how-to-get-the-cursor-position-in-the-textarea/

热点排行