免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2741 | 回复: 0
打印 上一主题 下一主题

Flex TextInput tooltip 当超过组件长度时显示 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-10-31 17:52 |只看该作者 |倒序浏览
Flex TextInput tooltip 当超过组件长度时显示



如标题所说,直接上代码

Java代码
  1. 1.protected function changeHandler(event:TextOperationEvent){   
  2. 2.//通过UIComponent的measureText方法得到TextLineMetrics,它的width就能得到输入框字符所占的真实width   
  3. 3.var charsWidth:int = txtInput.measureText(txtInput.text).width;   
  4. 4.if (charsWidth > txtInput.width) //与textinput的width进行比较   
  5. 5.{   
  6. 6.    txtInput.toolTip = txtInput.text;   
  7. 7.}   
  8. 8.else  
  9. 9.{   
  10. 10.    txtInput.toolTip = "";   
  11. 11.}   
  12. 12.}   
  13. 13.  
  14. 14.<s:TextInput id="txtInput" change="changeHandler(event)"/>  
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP