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

TextField on html5 target only accessible with mouse after changing content programmatically #1285

Closed
chpla opened this issue Sep 27, 2016 · 4 comments

Comments

@chpla
Copy link

chpla commented Sep 27, 2016

When I use a dynamic TextField for user input on html5 targets, and I programmatically change its content, the text field loses focus and becomes inaccessible except through clicking on it again with the mouse. The event handlers for the focus get called properly if I try focusing it through other means (e.g. by setting stage.focus), but it is not possible to input text with the keyboard unless the text field is clicked on. After clicking on it once, it remains accessible until the content is again changed in the program.

@jgranick
Copy link
Member

jgranick commented Sep 27, 2016

This is working for me on the latest source of OpenFL and Lime:

package;


import openfl.display.Sprite;
import openfl.events.TimerEvent;
import openfl.text.TextField;
import openfl.utils.Timer;


class Main extends Sprite {


    public function new () {

        super ();

        var textField = new TextField ();
        textField.text = "Hello";
        textField.type = INPUT;
        addChild (textField);

        var timer = new Timer (2000);
        timer.addEventListener (TimerEvent.TIMER, function (_) {

            textField.text += "h";

        });
        timer.start ();

    }


}

(I can click into the field, type or remove characters, and focus persists, even as additional characters are added at the end)

Are you using -Dcanvas or -Ddom? The above is working for GL. It is also possible that this was improved since the last release, or that there is something more complex happening in your code that is changing focus

@chpla
Copy link
Author

chpla commented Oct 12, 2016

If you modify it like this, the error occurs:

package;


import openfl.display.Sprite;
import openfl.events.TimerEvent;
import openfl.text.TextField;
import openfl.utils.Timer;


class Main extends Sprite {


    public function new () {

        super ();

        var textField = new TextField ();
        textField.text = "Hello";
        textField.type = INPUT;
        addChild (textField);

        var timer = new Timer (5000);
        timer.addEventListener (TimerEvent.TIMER, function (_) {

            textField.text = "";

        });
        timer.start ();

    }


}

@chpla
Copy link
Author

chpla commented Oct 12, 2016

(the important change is that I assign the text field something rather than just concatenating. Upon assigning text, it loses focus and must be clicked again to refocus.

@ibilon ibilon added this to the Improvements to TextField milestone Oct 21, 2016
@ibilon
Copy link
Member

ibilon commented Oct 21, 2016

The bug also happens on neko.

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

No branches or pull requests

3 participants