Flex 让TextArea 中的 Link 显示html tooltip
2009-06-29 23:30
197 查看
控件是
<mx:TextArea id="myTextArea" height="147" mouseMove="mOver(event)" editable="false" width="197" />
Custom Tooltip:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" implements="mx.core.IToolTip" color="#FFFFFF" width="182" height="216" fontSize="12" xmlns:ns1="*" verticalScrollPolicy="off" horizontalScrollPolicy="off" styleName="BoardFloat" mouseEnabled="false" >
<mx:Script>
<![CDATA[
import mx.controls.ToolTip;
import mx.controls.Label;
import mx.utils.ObjectProxy;
import mx.controls.Text;
private var mContentText:Text;
private var mTitleLabel:Label;
public var _text:String;
public function get text():String {
return _text;
}
public function set text(value:String):void {
setTipText(value);
}
public function setTipText(desc:String):void
{
if(mContentText==null)
{
mContentText=new Text();
mContentText.x=10;
mContentText.y=32;
mContentText.width=162;
mContentText.setStyle("letterSpacing","1");
addChild(mContentText);
}
mContentText.htmlText=desc;
validateNow();
mContentText.validateNow();
mContentText.height=mContentText.textHeight;
height=mContentText.textHeight+60;
}
]]>
</mx:Script>
</mx:Canvas>
添加事件:
myTextArea.addEventListener(TextEvent.LINK, linkListener);
function linkListener(evt:TextEvent):void{
mx.managers.ToolTipManager.toolTipClass = TipClass;
myTextArea.toolTip = "<font color=/"#ff0000/">abcd</font>";
}
function mOver(evt:MouseEvent):void{
//mx.managers.ToolTipManager.toolTipClass = ToolTip;
if(last_posx==0)
{
last_posx=evt.localX;
}
else{
if(Math.abs( evt.localX - last_posx ) >= 4){
mx.managers.ToolTipManager.toolTipClass = ToolTip;
myTextArea.toolTip = "";
last_posx=evt.localX ;
}
}
if(posy==0)
{
last_posy=evt.localY;
}
else{
if(Math.abs( evt.localY - last_posy ) >= 4){
mx.managers.ToolTipManager.toolTipClass = ToolTip;
myTextArea.toolTip = "";
last_posy=evt.localY;
}
}
}
<mx:TextArea id="myTextArea" height="147" mouseMove="mOver(event)" editable="false" width="197" />
Custom Tooltip:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" implements="mx.core.IToolTip" color="#FFFFFF" width="182" height="216" fontSize="12" xmlns:ns1="*" verticalScrollPolicy="off" horizontalScrollPolicy="off" styleName="BoardFloat" mouseEnabled="false" >
<mx:Script>
<![CDATA[
import mx.controls.ToolTip;
import mx.controls.Label;
import mx.utils.ObjectProxy;
import mx.controls.Text;
private var mContentText:Text;
private var mTitleLabel:Label;
public var _text:String;
public function get text():String {
return _text;
}
public function set text(value:String):void {
setTipText(value);
}
public function setTipText(desc:String):void
{
if(mContentText==null)
{
mContentText=new Text();
mContentText.x=10;
mContentText.y=32;
mContentText.width=162;
mContentText.setStyle("letterSpacing","1");
addChild(mContentText);
}
mContentText.htmlText=desc;
validateNow();
mContentText.validateNow();
mContentText.height=mContentText.textHeight;
height=mContentText.textHeight+60;
}
]]>
</mx:Script>
</mx:Canvas>
添加事件:
myTextArea.addEventListener(TextEvent.LINK, linkListener);
function linkListener(evt:TextEvent):void{
mx.managers.ToolTipManager.toolTipClass = TipClass;
myTextArea.toolTip = "<font color=/"#ff0000/">abcd</font>";
}
function mOver(evt:MouseEvent):void{
//mx.managers.ToolTipManager.toolTipClass = ToolTip;
if(last_posx==0)
{
last_posx=evt.localX;
}
else{
if(Math.abs( evt.localX - last_posx ) >= 4){
mx.managers.ToolTipManager.toolTipClass = ToolTip;
myTextArea.toolTip = "";
last_posx=evt.localX ;
}
}
if(posy==0)
{
last_posy=evt.localY;
}
else{
if(Math.abs( evt.localY - last_posy ) >= 4){
mx.managers.ToolTipManager.toolTipClass = ToolTip;
myTextArea.toolTip = "";
last_posy=evt.localY;
}
}
}
相关文章推荐
- html textarea 怎样才能不显示滚动条?
- 实现Flex的TextArea文本中关键字的高亮显示
- Flex中的字符集(比如在ToolTip里要换行显示信息)
- flex中设置错误和tooltip显示字体
- Flex中如何在用户按住TextArea滚动条(横竖方向)拖动时显示ToolTips
- Flex中的字符集(比如在ToolTip里要换行显示信息)
- FLEX:在DataGrid上显示Tooltip
- 去掉Html textarea 标签前面显示空格
- Flex :直接显示ToolTip和errorTip(不需要将鼠标移到组件上)
- 在textarea中显示html页面的javascript代码
- 如何在textarea中显示html代码
- textarea的换行符处理以及正确的在Html中显示
- Html中的textarea 的内容不居左显示问题
- HTML TextArea的值保存后显示错误问题。
- HTML联动下拉框的内容使用js显示到文本域textarea
- 解决textarea内容保存到MySQL再显示到html中没有换行的问题
- Flex中利用ToolTipManager类设定toolTip显示时间/停留时间的例子
- Flex4,textArea控件的htmlText属性
- Html中textarea高亮编辑显示代码插件
- textarea的换行符处理以及正确的在Html中显示