Просмотр полной версии : Как в раскрывающимся списке ограничить число символов для ввода?
MedvedevA
28.05.2008, 18:12
Как в раскрывающимся списке ограничить число символов для ввода?
<mx:ComboBox x="563.3" y="137" id="phone_sb" width="140" editable="true">
Параметра как в тестовом поле maxChars нету ж.
Параметра как в тестовом поле maxChars нету ж.
Но есть протектное свойство textInput (http://livedocs.adobe.com/flex/2/langref/mx/controls/ComboBase.html#textInput) Чтобы до него добраться, надо создать наследника данного компонента.
MedvedevA
29.05.2008, 12:08
Люди помогите добратся до Protected свойства textInput класса mx.controls.ComboBox
Что тут не правильно? Пишет ошибку "Incompatible override".
package myComponents
{
import mx.controls.ComboBox;
import mx.controls.TextInput;
public class myComboBox extends ComboBox
{
override public function get textInput():TextInput {
return super.textInput;
}
}
}
Потому что нельзя изменять уровень доступа гетера.
Напишите что-то вроде:
public function get inputText():TextInput {
return super.textInput;
}
Molecula
29.05.2008, 13:46
Вуаля, дальше сами:
Класс:
package {
import mx.controls.ComboBox;
import flash.events.Event;
import flash.events.FocusEvent;
public class CustomCombo extends ComboBox{
private var _myText:String = "";
public function CustomCombo()
{
}
override protected function textInput_changeHandler(event:Event):void {
_myText = this.textInput.text;
this.textInput.maxChars = 2;
//this.open();
}
override public function close(trigger:Event=null):void{
super.close(trigger);
if (this.text == ""){
this.selectedIndex = 0;
}
}
override protected function focusOutHandler(event:FocusEvent):void{
super.focusOutHandler(event);
if (this.text == ""){
this.selectedIndex = 0;
}
this.editable = false;
}
override protected function focusInHandler(event:FocusEvent):void{
super.focusInHandler(event);
this.editable = true;
this.textInput.setFocus();
}
}
}
В МХМЛе::
<mx:Script>
<![CDATA[
import CustomCombo;
private function init():void{
var c:CustomCombo = new CustomCombo();
addChild(c);
}
]]>
</mx:Script>
MedvedevA
29.05.2008, 16:42
Вуаля, дальше сами:
Спасибо. Сработало.
package myComponents
{
import mx.controls.ComboBox;
import mx.controls.TextInput;
import flash.events.Event;
public class myComboBox extends ComboBox
{
public function myComboBox()
{
super();
}
override protected function textInput_changeHandler(event:Event):void {
this.textInput.maxChars = 4;
}
}
}
Вот только не понял, а что делает функция textInput_changeHandler???
Molecula
29.05.2008, 17:00
Handles changes to the TextInput that serves as the editable text field in the component.
Работает на vBulletin ® версия 3.7.3. Copyright ©2000-2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Copyright © 1999-2008 Flasher.ru. All rights reserved.