[HTML5 - Lime 5.5.0 - OpenFl 6.1.2] Some problems with TextFields: right autosize, maxChars and restrict

Hi,
I have tested the new TextFields, and I have found that there are still some problems:

  • if you set RIGHT autosize the right alignment of the textbox will be delayed and the textfield will jump left and right when the text is updated (both INPUT and DYNAMIC textfield types).

  • the maxChars parameter limits the number of “visible” characters to n, but you can insert n+: if I set maxChars to 10 and I type “justanothertest” I will see “justanothe”, but if I want to delete the whole content of the textfield I have to push backspace/delete 15 times to delete “rtest” too.

  • even if you set “restrict” property, i.e. “0-9” to limit the insertable characters, you can still insert the others, even if they become invisible.

You can test these problems with this code:

var centerLine: Shape = new Shape();
centerLine.graphics.beginFill(0xffffff);
centerLine.graphics.lineStyle(1, 0x00ff00);
centerLine.graphics.lineTo(0, 720);
centerLine.graphics.endFill();
centerLine.x = 640;
addChild(centerLine);

var font: Font = Assets.getFont ("assets/fonts/Myriad_Pro.ttf");

// TEXT FORMAT ---------------------------------------->
var tfFormat: TextFormat = new TextFormat();

if (font != null) {
Font.registerFont(Type.getClass(font));
tfFormat.font	= font.fontName;
}
						
tfFormat.size	= 30;
tfFormat.align	= TextFormatAlign.LEFT;
tfFormat.color	= 0xffff00;

// TEXT FIELD ----------------------------------------->
var tf: TextField = new TextField();
tf.x = centerLine.x;
tf.y = 100;
tf.defaultTextFormat = tfFormat;
tf.embedFonts	= true;

tf.type		= TextFieldType.INPUT/*TextFieldType.DYNAMIC*/;
tf.autoSize	= TextFieldAutoSize.RIGHT;
tf.selectable	= true;
tf.border		= true;
tf.borderColor	= 0xffffff;
tf.maxChars	= 10;
tf.restrict = "0-9";

addChild(tf);

If you insert “justanothertest” you will see “justanothe”, but tf.text will be “justanothertest” instead of “justanothe”.

If you then try to insert “01234ab678cv”, you will see “01234678”, but tf.text will be “01234ab678cv” instead of “01234678”.

While inserting the characters you’ll notice that the textfield moves left and right trying to align to the set X, with a delay.

Did anyone notice these problems? Is it just me?

I don’t know how to use Git, do you know if these bugs have already been flagged up?

Some rendering improvements in Lime/OpenFL today

Before:

Now:

This was caused by differences in our native layout library and Cairo rendering, but they should be synced better now

1 Like

Very good! Thank you!

I just opened an issue:

Thank you Joshua, again! :wink: