Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCIMEDispatcher has fixed prompt on devices #1095

Open
freezeepopprice opened this issue Aug 22, 2013 · 1 comment
Open

CCIMEDispatcher has fixed prompt on devices #1095

freezeepopprice opened this issue Aug 22, 2013 · 1 comment

Comments

@freezeepopprice
Copy link

Currently the prompt used by the CCIMEDispatcher is fixed as:

"please enter your word:"

It would be better if this could be set from the outside as it does with the current input string value. My suggestion would be to change the _focusDomInput method to the following (which allows the delegate to suggest the string:

    _focusDomInput:function (delegate) {
        if(cc.Browser.isMobile){
            this.impl._delegateWithIme = delegate;
            delegate.didAttachWithIME();
            //prompt
            this._currentInputString = delegate.getString ? delegate.getString() : "";
            var promptString = delegate.getPrompt ? delegate.getPrompt() : "please enter your word:";
            var userInput = prompt(promptString, this._currentInputString);
            if(userInput != null)
                this._processDomInputString(userInput);
            this.dispatchInsertText("\n", 1);
        }else{
            this.impl._delegateWithIme = delegate;
            this._currentInputString = delegate.getString ? delegate.getString() : "";
            delegate.didAttachWithIME();
            this._domInputControl.focus();
            this._domInputControl.value = this._currentInputString;
            this._domInputControlTranslate();
        }
    },

Then as a default the delegate in the textfield can provide a prompt (and can return the placeholder text). I do not know if this is considered a strong interface that needs to stay compatible with cocos2d-x though. The method added to the textfield would be.

    getPrompt:function () {
        return this._placeHolder;
    },
@dingpinglv
Copy link
Contributor

This is a good idea.

Could you please send a pull request to us?

Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants