Jump to content

Anyone interested in canvas inputs?


Recommended Posts

Hello Guys,

I'm currently working on this plugin for PIXI: http://mokgames.com/playground/pixi.dom/

Those input elements are actual Sprites.

See also: http://www.html5gamedevs.com/topic/9668-pixi-input-elements/

I have never written a plugin for Phaser, but I believe that it is pretty easy to port it.

So I'm curious if anyone is interested to have those ported or not. If yes, then I will publish a Phaser port too.

It will probably take a few more days until I have implemented all the things that I have in my mind.

So, does anyone want this to be usable with Phaser?


Link to comment
Share on other sites

Thanks lewster!

I'm doing this by having 1 real input field set to opacity 0, width 1px, height 1px positioned outside of the screen.

When you select an input sprite, then the hidden input tag gets focused and it's content gets set to the sprites input values.

That way all shortcuts e.g. ctrl+c, ctrl+x, etc, work like a charm and it's really easy to just grab the cursor position by the inputs selectionStart/selectionEnd values.

There are still some bugs and probably a lot to optimize tho.

I hope it won't be too hard to port this to Phaser and I have no idea for the namespace yet.

In my PIXI version I use:

PIXI.InputObject (inherit from PIXI.Sprite)

PIXI.ButtonFactory(this draws the background for the sprite)

PIXI.Button (inherit from PIXI.InputObject)

PIXI.Input (inherit from PIXI.InputObject)

PIXI.Select (inherit from PIXI.InputObject)

There will most likely also be PIXI.Checkbox and PIXI.Radio, those are like the easiest elements (just a sprite changing texture on checked/unchecked)

I'm not sure yet how hard it would be to also create an PIXI.Textarea, this mostly because of the scrollbars.

Other than that, There could also be PIXI.ScrollableContainer.

Any suggestion for a good namespace when using this with Phaser?

I haven't looked it up yet, so I can't tell what I can use and what I should use.

I don't want to conflict with future Phaser releases either.


Not on GitHub yet. I don't want anyone to grab a half finished plugin.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...