We are building a proof of concept using Titanium to wrap an existing web application but have two specific issues: 1. We are unable to use fireEvent within the web application to push events up to the Titanium application. Our web application has a number of external links so we obviously need to hijack these and route them through Ti.Platform.openURL(url); This does not seem to be possible as the remote web application does not seem to have scope to Ti to be able to execute a Ti.App.fireEvent(); 2. The WebView does not seem to be able to listen for 'swipe' events. If we add event listeners for 'touch start' or 'touch move' and these work but for some reason not swipe.
In both cases we are using the the 2.0.2 SDK and are testing on android targets (emulator and ASUS Transformer)
Thanks in advance
2 Answers
Only local HTML can call Ti.App.fireEvent(). We get around this by having our web application send JSON objects down to our app, and we then use that data to build HTML in the client.
In a quick test, I was able to get swipe events. It did have the unfortunate side effect of preventing scrolling in my webview, though.
Just whipped up a simple example:
var w = Ti.UI.createWindow ({}); var markup = '<html><head><title>test</title></head><body>test</body></html>'; var wv = Ti.UI.createWebView({ html: markup, scalesPagesToFit: true, top: 0, left: 0, right: 0, bottom: 0, enableZoomControls: false, backgroundColor: '#fff' }); wv.addEventListener ('swipe', function (e) { Ti.API.debug ('[swipe]'); }); w.add (wv); w.open ();I get swipe events. It also works with an external URL:
var w = Ti.UI.createWindow ({}); var markup = '<html><head><title>test</title></head><body>test</body></html>'; var wv = Ti.UI.createWebView({ //html: markup, url: 'http://www.google.com/', scalesPagesToFit: true, top: 0, left: 0, right: 0, bottom: 0, enableZoomControls: false, backgroundColor: '#fff' }); wv.addEventListener ('swipe', function (e) { Ti.API.debug ('[swipe]'); }); w.add (wv); w.open ();All this on iphone simulator. Haven't tried Android.
Your Answer
Think you can help? Login to answer this question!