How to give focus to ccui.textField for immediate input text?

I tried
this.textField1.setFocused(true);
and
this.textField1.requestFocus(true);

but nothing happend

I want load gameLayer and just input text without click to widget.
Is it possible?

@madgod,

Have you checked with this.textField1.attachWithIME(); method?

2 Likes

Yes, i try it. I think, it`s for phone version, but not for web. No effect at all.

May be i need call this function after scene loading, but i dont know where it is in code.

cc.game.onStart = function(){
	cc.view.setDesignResolutionSize(320, 240, cc.ResolutionPolicy.SHOW_ALL);
	cc.LoaderScene.preload([], function () {
		cc.director.runScene( new gameScene());
	}, this);
	
};
cc.game.run("gameCanvas");

How i must write code,which run after this section?

I hope gameScene will be :

var gameSceneLayer = cc.Layer.extend({

    ctor:function () {
        //////////////////////////////
        // 1. super init first
        this._super();

        //Here you can write code. 
    }
});

var gameScene = cc.Scene.extend({
    onEnter:function () {
        this._super();
        var layer = new gameSceneLayer();
        this.addChild(layer);
    }
});
2 Likes

Yes, same as the samples code.
But, i think that ctor and init section goes before paint or bake section.
I need function or place for code that goes after all scene load and ready.

YES! You was right!
this.textField1.attachWithIME();
works

but i put this code in function that called in

this.scheduleOnce(this.function);

And its work!

Thanks!

1 Like

Instead of ctor or init method

check with:

onEnterTransitionDidFinish:function () {
        cc.log("SceneTestLayer1#onEnterTransitionDidFinish");
        this._super();
    },

Not shure if it is not my level of programming )
I just newbie.

Is it something like overload function?

@madgod,

Its Okay.

Yeah its overload function