解决方法
默认情况下,您无法执行此操作.但是,如果扩展ComboBox,则可以轻松添加此功能.这是一个简单的例子,它是一个粗略的版本,可能需要测试/调整,但它显示了如何实现这一目标.
package { import mx.controls.ComboBox; import mx.core.UIComponent; public class ComboBox2 extends ComboBox { public function ComboBox2() { super(); } protected var textInputReplacement:UIComponent; override protected function createChildren():void { super.createChildren(); if ( !textInputReplacement ) { if ( itemRenderer != null ) { //remove the default textInput removeChild(textInput); //create a new itemRenderer to use in place of the text input textInputReplacement = itemRenderer.newInstance(); addChild(textInputReplacement); } } } override protected function updatedisplayList(unscaledWidth:Number,unscaledHeight:Number):void { super.updatedisplayList(unscaledWidth,unscaledHeight); if ( textInputReplacement ) { textInputReplacement.width = unscaledWidth; textInputReplacement.height = unscaledHeight; } } } }
原文地址:https://www.jb51.cc/flex/174277.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。