Android Question Webview and swipes...

eps

Expert
Licensed User
Longtime User
I've got an issue with a Webview (using the excellent WebViewExtras2 library).

I am using WebViewExtras2 to then display some babylonjs - so a 3D game.

It's very simple and I'm just trying to work out how things hang together..

At the moment the process successfully serves 'touch events' through to the babylonjs and I can process those, but when trying to pass or process a swipe or a touch down and then move and then touch up event as it were it doesn't seem to work as well.

I was hoping that someone else may well have tried the same/similar or understood the mechanics between the two - I'm not sure if I'm facing a WebView or a Babylonjs problem.. It seems to be a WebView problem and that I'm not passing the event on correctly but I'm not 100% sure.

I can post some code if it helps - there's not a lot of B4A.. (below) as it all happens within HTML and JS for babylonjs. Within babylonjs they have a virtual joystick and when using a mouse in IE you can have it depressed all the time and then move the pointer, but for Android it seems to detect the initial 'down' event and a swipe or fling, but you have to remove your finger from the screen and redo the motions.. It should work 'continuously' e.g. you just hold your finger on the screen and move it around to control an object in the game (which is how the IE version seems to work).

So it works of sorts, but not quite as I was hoping or expecting on Android.

B4X:
    wv.Initialize("wv")
    wv.ZoomEnabled = False

    WebViewExtras1.Initialize(wv)

     Dim WebChromeClient1 AsDefaultWebChromeClient

  WebChromeClient1.Initialize("WebChromeClient1")

  WebViewExtras1.SetWebChromeClient(WebChromeClient1)

    Activity.AddView(WebViewExtras1, 0, 0, 100%x, 100%y)
  WebViewExtras1.LoadUrl("file:///android_asset/index.html")


  Dim jo As JavaObject = Activity

  jo.RunMethodJO("getContext", Null).RunMethodJO("getWindow", Null).RunMethod("setSoftInputMode", _

    Array As Object(0x20))

  ActivityParent = jo.RunMethodJO("getParent", Null)

I added in the RunMethodJO but it doesn't seem to have much if any affect.

I was wondering if I should be handling a JO event or call of some sort.. but again I'm not entirely sure!

Apologies for the vagueness - it's not intentional, I'm just attempting to work out how to utilise babylonjs within Android - it doesn't seem to have been used much before - well not in B4A at least. They seem to expect it to be used in PC environments and the usual Microsoft environments of IE or Windows Phones..

Any help or links to information regarding this would be gratefully received!

Thanks!
 

eps

Expert
Licensed User
Longtime User
Phew! I've got this sorted out now :) Within Babylonjs I used pep.js instead of hand.js and it works much better :) and added
B4X:
  touch-action="none"
to the canvas within the html as well
 
Upvote 0
Top