Hi, all. In my app I’m using a webView to display a page from a mobile site. It works fine with one small problem. On the mobile site’s page there is a back button which a user might confuse for the app’s true back button which is up at the top of the screen. If a user taps the mobile site’s back button the webView just disappears leaving a big empty space on the screen. The app’s navigation is still visable at the top, so it’s not fatal, but it’s not ideal either.
I’ve tried setting up a listener to look for any sort of event triggered by clicking the mobile site’s back button. But I can’t detect any on the first screen, unless you navigate to a second screen on the mobile site and then the listener returns all the expected information. The back button there responds with an event type, “history.”
I also tried setting up an invisible button to capture the touch events right around the mobile site’s back button but that won’t work because all display objects site behind native ones.
I also tried capturing touch events by x,y coordinates, to no luck either.
I’m fairly stuck at this stage. Any thoughts would be greatly appreciated.
Here’s the basics of the code I’m dealing with:
[lua]
function webViewListener( event )
print("Event type: "…event.type)
print("URL: "…event.url)
if event.errorCode then
native.showAlert( “Error!”, event.errorMessage, { “OK” } )
end
if event.type == “history” then
storyboard.gotoScene( “previous screen”, “slideRight”, 400 )
webView:removeSelf()
webView = nil
end
end
webView = native.newWebView( 0, 0, 320, 437)
webView:request( “http://m.airforce.com/recruiter-locator/” )
webView.anchorX, webView.anchorY = 0, 0
webView.y = 131
webView:addEventListener( “urlRequest”, webViewListener )
[/lua]