HTML5 touches does not work on all devices

When I try to listen to events from the touches, it works on many androids devices, and as far as I know, no IOS devices.

From the generated js :

flash_Lib.get_current().get_stage().addEventListener("touchBegin",$bind(this,this.handleTouchBegin));

After this line is called, the handleTouchBegin is never called.

I’m using openfl through HaxeFlixel but after a lot of testings, it isn’t related to HaxeFlixel.

Also, I don’t get why the event is called “touchBegin” whereas it should be “touchstart”. But replacing in the code “touchBegin” by “touchstart” doesn’t change anything.

Is anyone experiencing this issue ?

EDIT:

flash_display_Stage.prototype method getOnTouch is triggered whereas method onTouch is never triggered on IOS

If you would like to explore further, the class you are looking for is “lime.ui.Window”, “registerWindow” adds the event listeners, and “handleEvent” is where it processes them. Is this specific to your project, or does it occur even with PiratePig or other sample projects? (or is that fine because it looks for mouse, not touch events)?

The problem is that touch events shouldn’t be attached to window object but to document object.

I will try the demos but I’m pretty sure the problem will remain the same.

It’s listening to the Lime window element, which is a DIV usually. Perhaps it needs to listen to the full document instead of a child element in some devices?

Well, in my output. Events are bounds to the window target in the flash.display.Stage object

var o = window;
o.addEventListener("touchmove",this.getOnTouch(0)); 
o.addEventListener("toucheend",this.getOnTouch(2)); 
...

I’m pretty sure this var o = window is configurable somewhere to target the DIV element ?

If it were listening to a child element, it should work since it’s part of the DOM, however, a Window object is not part of the DOM and therefore is not taken into account in some devices browsers.

Strange, this is what the source looks like: https://github.com/openfl/lime/blob/master/lime/ui/TouchEventManager.hx#L128-L147

In the source you gave me, it is attached to the window ?

window.element.addEventListener ("touchstart", handleEvent, true);
window.element.addEventListener ("touchmove", handleEvent, true);
window.element.addEventListener ("touchend", handleEvent, true);

window in this case is a lime.ui.Window, so window.element should be the host DIV or Canvas element for where the project was embedded

…but perhaps the fact that the variable is called “window” could cause problems on certain browsers, could always try using _window:Window and _window.element to double-check if this is the problem :philosoraptor:

I’ll try tomorrow at the office and tell you

Hmmm,

I’m using lime 1,0,1 cause 2.0.x cause errors with HaxeFlixel or OpenFL, dunno. This might be a problem then.

Lime is now using bitfive ? Cause it tries to compile with it whereas it didn’t

EDIT: I don’t see any string “touchstart” in lime 1.0.1

If you’re having trouble with bitfive, you can try compiling using -Dno-custom-backend, which should disable OpenFL custom backend support, so it uses the standard HTML5 backend instead

Seems like it’s not working.

Here is the error log:

C:/HaxeToolkit/haxe/lib/openfl-bitfive/2,0,1/openfl/Assets.hx:487: characters 31-57 : DefaultAssetLibrary should be openfl.AssetLibrary
C:/HaxeToolkit/haxe/lib/openfl-bitfive/2,0,1/openfl/Assets.hx:487: characters 31-57 : For function argument 'library'
C:/HaxeToolkit/haxe/lib/lime/2,0,0-alpha,8/lime/system/System.hx:75: characters 2-35 : Class<ApplicationMain> has no field config
C:/HaxeToolkit/haxe/lib/lime/2,0,0-alpha,8/lime/system/System.hx:76: characters 2-32 : Class<ApplicationMain> has no field config
C:/HaxeToolkit/haxe/lib/lime/2,0,0-alpha,8/lime/system/System.hx:77: characters 2-24 : Class<ApplicationMain> has no field create

It’s working as it should (though there’s an annoying bug that causes the system cursor to always show up), -Dno-custom-backend is meant to be added before you’re calling in Flixel:

<set name="no-custom-backend" />
<haxelib name="flixel"/>
1 Like

Oh !

My bad, I was using <haxedef> instead of <set>.

Thanks !

Yeah, we need to look at making sure our support of hiding the mouse cursor made it to Lime, it was in OpenFL HTML5 but it might have been lost in the translation