azerion / phaser-input

Adds input boxes to Phaser like CanvasInput, but also works for WebGL and Mobile, made for Phaser only.
MIT License
203 stars 64 forks source link

Expose focusIn / focusOut signals. #40

Closed henriquelalves closed 7 years ago

henriquelalves commented 7 years ago

This is not an API bug per se, but it just weird for it not to be a native feature.

What I needed was to simply add a callback to endFocus of an inputField; problem is, from what I looked on the code, InputElement does have public signals:

public focusIn: Phaser.Signal = new Phaser.Signal(); public focusOut: Phaser.Signal = new Phaser.Signal();

But InputElement itself is a private element of InputElement, therefore hiding both signals from user access. My solution was to hardcode a callback using closures, as seen on this gist.

I think it would make more sense to expose both signals as events in the inputField object.

PS: I tried messing with the typescript code, but I'm a Grunt newbie and I couldn't build from source.

AleBles commented 7 years ago

makes sense to me, consider it done