Detecting screen touch on newWebView

Hello,

do WebView objects (since not being part of the Corona GL and always appearing on top) ignore runtime events?   …basically i have a timer that resets on every screen touch (as an idle-time counter) but will not reset when user interacts with webviews. Is this a “native” limitation and if, are there workarounds?

Thanks.

The touch inputs events are captured by the webview and not passed on to Corona.

You may be able to inject custom events into Corona.  See the example that comes with Corona for how they dispatched an event to Corona when you press the button in the sample. 

(~\Corona SDK\Sample Code\Interface\WebOverlay\main.lua)

You cannot inject a touch event into the Corona event system however, so you’ll need to handle any injected events via your own Runtime listeners and code.

You could use the webViews callback listener to know if there has been any screen interaction (clicking an href, etc.).  That would kinda work for an idle timer?

Using the callback method “kinda” worked thanks :slight_smile:

By detecting new url request i was partially able to reset the timers. Unfortunately the content i am displaying in the webView is “self contained”, meaning it does not navigate out of the initial url (as intended). Therefore limiting the usefulness of the callback method, at least in the way I understand it.

mumble mumble…

If you’re in control of the HTML, maybe you could wrap the entire HTML code that’s going in to a view and put it in a <div> then wrap that in an in-page anchor:  “#screentouch” and look for an even where that’s the URL.  There is some example code here: https://docs.coronalabs.com/api/library/native/showWebPopup.html (older not-recommeded webview) that shows how a form handler could have a URL that doesn’t do anything but is enough to trigger events back on the Corona side that might inspire you on how to manage this.

Rob

Interesting. I will keep this in mind for another project i’m working on, where I do have control over the HTML.

In the specific case unfortunately i do not. 

I am displaying a matterport 3D virtual tour. They host the media on theyr CDN’s and only provide you with direct links.

I’ts not a MAJOR setback, but still annoying if a customer gets “kicked” out of navigating a 3D world unexpectedly.

Cant suspend the idle timer either, it would defeat the purpose of the timer itself (…sponsor info shows after timer resets).

Would it be possible to modify the webView widget to have a similar property (pass information to Corona)? …i mean would it make sense to put in a feature request? …together with the already requested ability to remove the annoying HUGE zoom buttons in the webView.  :smiley:

Adding a feature request or up-voting another request with the same feature is your best bet.  

You could perhaps create a frameset and in the main frame display the content you are streaming and in another frame run a meta-refresh of say 30 secs of a blank html page.  Rob would need to confirm this but that should give you a callback event you can monitor?

The touch inputs events are captured by the webview and not passed on to Corona.

You may be able to inject custom events into Corona.  See the example that comes with Corona for how they dispatched an event to Corona when you press the button in the sample. 

(~\Corona SDK\Sample Code\Interface\WebOverlay\main.lua)

You cannot inject a touch event into the Corona event system however, so you’ll need to handle any injected events via your own Runtime listeners and code.

You could use the webViews callback listener to know if there has been any screen interaction (clicking an href, etc.).  That would kinda work for an idle timer?

Using the callback method “kinda” worked thanks :slight_smile:

By detecting new url request i was partially able to reset the timers. Unfortunately the content i am displaying in the webView is “self contained”, meaning it does not navigate out of the initial url (as intended). Therefore limiting the usefulness of the callback method, at least in the way I understand it.

mumble mumble…

If you’re in control of the HTML, maybe you could wrap the entire HTML code that’s going in to a view and put it in a <div> then wrap that in an in-page anchor:  “#screentouch” and look for an even where that’s the URL.  There is some example code here: https://docs.coronalabs.com/api/library/native/showWebPopup.html (older not-recommeded webview) that shows how a form handler could have a URL that doesn’t do anything but is enough to trigger events back on the Corona side that might inspire you on how to manage this.

Rob

Interesting. I will keep this in mind for another project i’m working on, where I do have control over the HTML.

In the specific case unfortunately i do not. 

I am displaying a matterport 3D virtual tour. They host the media on theyr CDN’s and only provide you with direct links.

I’ts not a MAJOR setback, but still annoying if a customer gets “kicked” out of navigating a 3D world unexpectedly.

Cant suspend the idle timer either, it would defeat the purpose of the timer itself (…sponsor info shows after timer resets).

Would it be possible to modify the webView widget to have a similar property (pass information to Corona)? …i mean would it make sense to put in a feature request? …together with the already requested ability to remove the annoying HUGE zoom buttons in the webView.  :smiley:

Adding a feature request or up-voting another request with the same feature is your best bet.  

You could perhaps create a frameset and in the main frame display the content you are streaming and in another frame run a meta-refresh of say 30 secs of a blank html page.  Rob would need to confirm this but that should give you a callback event you can monitor?