[SOLVED] Input textfield crashes when using Mac or Linux

The demo I have found for allowing text field input works fine when targeting windows, but throws an error when targeting mac or linux.

The error states “pointer being released was not allocated”, and I can’t see how it applies here. Any help in fixing this bug would be greatly appreciated.

EDIT: To be a little more specific, i’ve found this is to do with the textfield.text property - if this is set as a default the program will crash with the error above. If this line is removed the program will initialize, but clicking inside the textfield causes the same error.

package;
import openfl.display.Sprite;
import openfl.events.Event;
import openfl.text.TextField;
import openfl.text.TextFieldType;
import openfl.text.TextFormat;
class Main extends Sprite {
	
	
	public function new () {
		
		super ();
		
		addEventListener(Event.ADDED_TO_STAGE, init);
		
	}
	
	private function init(e:Event):Void 
	{
		removeEventListener(Event.ADDED_TO_STAGE, init);
		
		var textfield = new TextField();
		textfield.x = 540;
		textfield.y = 440;
		textfield.type = TextFieldType.INPUT;
		textfield.selectable = true;
		textfield.textColor = 0x000000;
		textfield.border = true;
		textfield.borderColor = 0xFFFF00;
		textfield.background = true;
		textfield.backgroundColor = 0xFFFFFF;
		textfield.text = 'sample';
		textfield.width = 200;
		textfield.height = 40;
		textfield.setTextFormat(new TextFormat(null, 32));
		
		//Mobile stuff
		#if (android || ios)
		textfield.needsSoftKeyboard = true;
		//textfield.softKeyboardInputAreaOfInterest = new Rectangle(540, 440, 200, 40);
		textfield.moveForSoftKeyboard = true;
		#end
		
		addChild(textfield);
	}
	
	
}

What version of lime are you using? I was having problems with texts using lime 2.9.1 so I downgraded to 2.9.0

haxelib set lime 2.9.0

I am experiencing the same issue with text fields. They work fine with html5 but when call compiling to neko the window crashes when adding to the stage.

This has fixed the issue on Mac, and I’ll try it on Linux in the next few days. Thanks!

Using setTextFormat before setting defaultTextFormat is generally not practice. When setTextFormat has been properly implemented, you will be required to set defaultTextFormat to resolve null errors as the source for the former function does not touch the latter.