【发布时间】:2011-07-27 12:20:18
【问题描述】:
标题中几乎描述了我的问题。只是一些细节.. 我正在创建一个自定义组件(基于 ComboBox)并覆盖一些基本方法。最近我发现当我以百分比而不是固定宽度设置它的宽度时,它的行为很奇怪。它倾向于不断调用commitProperties 方法并最终失败。当我将它的宽度设置为固定值时 - 一切都像魅力一样。我缺少什么来实现?这是一些代码..
override protected function commitProperties():void {
super.commitProperties();
//some stuff ...
TextInput(textInput).setSelection(cursorPosition, cursorPosition);
if (cursorPosition == textInput.text.length || cursorPosition == 0) {
TextInput(textInput).horizontalScrollPosition = (cursorPosition == 0) ? 0 : textInput.width;
}
}
在这两种情况下,textInput.width 都正确返回了计算值。
而且,如果需要的话,只是为了一个案例:
override protected function measure():void {
super.measure();
measuredWidth = 160;
}
我不确定是否还需要其他东西……请问是否需要。 在此先感谢:)
【问题讨论】:
标签: apache-flex custom-component measurement