0

我正在为 android 和 ios 编写和播放移动应用程序,我必须使用 TLFTextField 因为我需要 RTL (heb)。
当我单击文本框并设置焦点时,我遇到了各种可渗透的 TLFTextField
第一个事件,SoftKeyboard 没有显示,所以我必须从代​​码中显示它,然后即使键盘打开,文本框也没有'没有按键并保持空白。欢迎任何想法或建议?

    public function BaseView()
    {
        super();
        this.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATE,onActive); 
        this.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE,onDeactive);
    }
    protected function onDeactive(event:SoftKeyboardEvent):void
    {
        isKeyBordOpen = false;
        trace("deactive")

    }

    protected function onActive(event:SoftKeyboardEvent):void
    {
        isKeyBordOpen = true;
        trace("Active: " + event.type)
    }

    internal function addEventToTextFiled(textBox:TLFTextField):void
    {
        textBox.addEventListener(FocusEvent.FOCUS_IN,onFocus,false,0,true);
        textBox.addEventListener(FocusEvent.FOCUS_OUT,onOutFocus,false,0,true);
    }

    internal function removeEventToTextFiled(textBox:TLFTextField):void
    {
        textBox.removeEventListener(FocusEvent.FOCUS_IN,onFocus);
        textBox.removeEventListener(FocusEvent.FOCUS_OUT,onOutFocus);
    }


    internal function onOutFocus(event:FocusEvent):void
    {
        var txt:TLFTextField = event.currentTarget as TLFTextField;
        setText(txt,txt.text);
    }

    internal function onFocus(event:FocusEvent):void
    {
        var txt:TLFTextField = event.currentTarget as TLFTextField;

        if(isKeyBordOpen == false)
        {
            var isRisie:Boolean = txt.requestSoftKeyboard();
            trace("isRisie:Boolean " + isRisie)
            stage.focus = txt 
        }
        setBlock(txt);
    }   

    internal function setText(textBox:TLFTextField,txt:String):void
    {
        txt = StringUtil.trim(txt," ");
        textBox.needsSoftKeyboard = true;
        if(txt != null && txt.length > 0)
        {
            setBlock(textBox);
            textBox.text = txt;
        }
        else
        {
            setTrans(textBox);
        }
    }

    internal function setTrans(textBox:TLFTextField):void
    {
        textBox.background = false;
    }

    internal function setBlock(textBox:TLFTextField):void
    {
        textBox.background = true;
        textBox.backgroundColor = 0xffffff;
    }
4

1 回答 1

0

解决方案可能根本不使用此类,而是使用 StageText http://blogs.adobe.com/cantrell/archives/2011/09/native-text-input-with-stagetext.html

于 2013-03-21T09:39:27.147 回答