HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.92k stars 427 forks source link

Steal @Starmapo input text #3178

Open Geokureli opened 3 weeks ago

Geokureli commented 3 weeks ago

Just learned this exists, @Starmapo if you tried to show me this, before, I missed it. I saw Funkin was using it

I have not yet begun to consider the ramifications of this, so let's start with seeing if it clears coverage CI and code climate, I guess. If you could list - in detail - the changes, improvements and features of this that would be a great!

Geokureli commented 3 weeks ago

Because it extends TextField methods that don't fit flixel's checkstyle settings. looking into a way to suppress these

Starmapo commented 3 weeks ago

I'll list the improvements later once I can properly check the differences. I'd just like to warn you first that, at least in its current state, it does not compile for Flash, as the TextField extension sets the stage variable which is required for some of the input stuff to work, and this variable isn't able to be modified on Flash.

Geokureli commented 3 weeks ago

I'll list the improvements later once I can properly check the differences.

No rush!

I'd just like to warn you first that, at least in its current state, it does not compile for Flash, as the TextField extension sets the stage variable which is required for some of the input stuff to work, and this variable isn't able to be modified on Flash.

Aight, then we'll need a workaround

Geokureli commented 3 weeks ago

Also note: this is going to flixel, not flixel-ui. The plan for releasing this is:

Lastly, @ShaharMS made https://github.com/ShaharMS/texter. They wanted to put it in flixel as well, but I thought it should stay in flixel-ui, which was a bad call. We should study theirs, as well, it boasts about "RTL support", which would be nice!, and might work on flash, iunno

This also reminds me, we should make a demo for this, mostly so I'm aware of all it's features, in comparison to the old one

Starmapo commented 2 weeks ago

Unfortunately the Flash issue is deeper than I assumed, since this text input uses private variables and functions from OpenFL classes, which are not available when compiling to Flash. I suppose that's the consequence of relying heavily on OpenFL's text input implementation.

We should study [texter], as well, it boasts about "RTL support", which would be nice!, and might work on flash, iunno

It seems to extend the flixel-ui text input, so if that one works on Flash, I think texter would too.

ShaharMS commented 2 weeks ago

Unfortunately the Flash issue is deeper than I assumed, since this text input uses private variables and functions from OpenFL classes, which are not available when compiling to Flash. I suppose that's the consequence of relying heavily on OpenFL's text input implementation.

We should study [texter], as well, it boasts about "RTL support", which would be nice!, and might work on flash, iunno

It seems to extend the flixel-ui text input, so if that one works on Flash, I think texter would too.

IIRC texter's input text does work on flash, and i don't mind providing an implementation for flixel

the main question is how advanced we want the input to be (multiline, copy-paste, selection shortcuts...) all should be somewhat easy to implement if i remember my design from back then correctly

Starmapo commented 2 weeks ago

I believe the only thing missing from texter that's in my implementation is full support for text selection; other than that, it seems like a better contender for a text input inside the main Flixel library.

ShaharMS commented 2 weeks ago

yeah just noticed after doing some testing

for me there are 2 main question about the implementation:

the other stuff is pretty much settled i think (common shorcuts, multiline, alignments...)

Geokureli commented 2 weeks ago

Let's start with "what is the best way to detect character input and other text-related keyboard input". I'd like to make a standalone util for this. if possible, I would like to make things that work with both FlxText and FlxBitmapText

ShaharMS commented 2 weeks ago

Already done in texter, and not too complex - 3/2 event listeners:

TextInput for regulat text, KwyDown for keyboard shortcuts & special characters, and the focus one is for js for when you click out of the openfl element

Geokureli commented 2 weeks ago
  • window.onTextInput
  • window.onKeyDown
  • window.onFocusLost (needed in web)

Any chance you can reduce that down to barebones, I don't really understand what bidi means and the code is a little hard to follow.

what would be nice is if it reduced all events down to a single action that anything could implement, like

enum TypingAction
{
   ADD_CHAR(charCode:Int);
   MOVE_CURSOR(type:MoveCursorAction);
   MOVE_SELECTION(type:MoveCursorAction);
   COMMAND(cmd:TypingCommand);
}

enum MoveCursorAction
{
    LEFT;
    RIGHT;
    UP;
    DOWN;
    HOME;
    END;
    LINE_LEFT;
    LINE_RIGHT;
    WORD_LEFT;
    WORD_RIGHT;
}

enum TypingCommand
{
   COPY;
   CUT;
   PASTE;
   SELECT_ALL;
}
Starmapo commented 2 weeks ago

Let's start with "what is the best way to detect character input and other text-related keyboard input". I'd like to make a standalone util for this. if possible, I would like to make things that work with both FlxText and FlxBitmapText

I do like that idea, though does that mean the base FlxText and FlxBitmapText classes will have input support? Or will you still have to use extended classes like FlxInputText?

I ask because I'm down to write at least a draft of the code, I've finished up my final works for school so I'm a lot more free now.

Geokureli commented 2 weeks ago

I do like that idea, though does that mean the base FlxText and FlxBitmapText classes will have input support? Or will you still have to use extended classes like FlxInputText?

No, FlxText and FlxBitmapText will not have input, both will have extensions for input versions, the stand-alone tool will be there to unify the behavior of both

Starmapo commented 2 weeks ago

I've opened a draft for my new text input implementation here #3191. It's still heavily work-in-progress, any feedback or suggestions are very much appreciated, mainly in regards to the coding structure.