简体   繁体   English

移动设备上的TLFTextField(ios / android)

[英]TLFTextField on mobile device (ios/ android )

I am writing and air mobile app for android and ios and I have to use TLFTextField because I need RTL (heb). 我正在为Android和ios编写和空中移动应用程序,由于我需要RTL(heb),因此必须使用TLFTextField。
I encounter all kind of permeable working with TLFTextField 我遇到了使用TLFTextField进行的各种渗透性工作
first event when I click the text box and set the focus the SoftKeyboard did not show up so I had to make it show up from the code then even when the key board was open the text box didn't got the key press and stay empty. 当我单击文本框并设置焦点时,第一个事件没有显示SoftKeyboard,所以我不得不从代码中显示出来,然后即使在打开键盘的情况下,文本框也没有被按下并保持空白。 Any idea or suggestion will be welcome? 有什么想法或建议会受到欢迎吗?

    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;
    }

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM