`
ilkds41y
  • 浏览: 13377 次
社区版块
存档分类
最新评论

Flex工程里TextField在fp10.1下不能输入中文的解决办法

 
阅读更多

Flex工程里TextField在fp10.1下不能输入中文的解决办法
2011年02月07日
  前段时间项目测试突然发现中文输入不正常,有时IME会失效,反复测试后发现这是fp10.1的一个bug.
  然后提交到 http://bugs.adobe.com/jira/browse/FP-4813
  可是正式版的flashplayer已经发布了,要修复这个bug也要等到下个flashplayer版本 
  
  
  我们的项目可等不了那么久,于是找找其他解决办法, Google,百度后都没有提到过类似的问题.
  设置IME.enabled = true也不管用.
  仔细测试后发现:Flex的TextInput可以输入中文,既然flex的可要输入,那么TextField也应该可要输入中文的.
  于是翻开mx.controls.TextInput的源码仔细查看. 几经测试后终于在一处注释处发现了一点线索.
  We don't call IME.conversionMode here. We call it only on focusIn. Thus fringe cases like setting imeMode dynamically without moving focus, through keyboard events, wouldn't change the mode. Also getting imeMode asynch. from the server which gets delayed and set later after focusIn is not handled as having the text partly in one script and partly in another is not desirable.
  
既然说在获得焦点后设置imeMode,那么我是不是也应该在focuseIn后设置IME.enabled呢 
  
  
  说干就干,马上做了一个测试,果然成功了 
  
   困扰我多时的问题终于解决了 
  
  
  具体代码如下:
  input.addEventListener(FocusEvent.FOCUS_IN, focusInHandler);function focusInHandler(e:FocusEvent):void { IME.enabled = true;}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics