[TIMOB-2017] Android: WebView No Longer Fires Click Event
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2012-04-23T12:58:38.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 1.5.0, Release 2.1.0, Sprint 2012-08 |
| Components | Android |
| Labels | android, api, defect, module_webview, qe-testadded, regression |
| Reporter | Don Thorp |
| Assignee | Ping Wang |
| Created | 2011-04-15T03:08:13.000+0000 |
| Updated | 2012-08-23T18:06:46.000+0000 |
Description
Bill triaged the problem.
In April you added this code to disallow registering for touch on the WebView:
http://github.com/appcelerator/titanium_mobile/commit/d47e4e06456d033af0eede50469633054bfc65cc#L1R149"> http://github.com/appcelerator/titanium_mobile/commit/d47e4e06456d0...
I'm going to mark this as a regression since I didn't comment on the commit well enough to know if I disabled it on purpose. Will need to check interference with clickable items in a webview and scrolling.
Attachments
| File | Date | Size |
|---|---|---|
| app.js | 2011-04-15T03:08:14.000+0000 | 1194 |
| index.html | 2011-04-15T03:08:14.000+0000 | 774 |
i'm working on tests for this
It seems fine to me with clicking enabled. Before I commit and set to fixed-in-qa, can you (don) please look at see if this video shows me testing enough stuff? (my test files are attached in case you want to look at them.)
Video:
http://screencast.com/t/HBfiMexSS">http://screencast.com/t/HBfiMexSS
(from [dcc312507064f1a53a2ff05919b85817c8f61aac]) [#2017 state:fixed-in-qa] Re-enable touch for WebView. It had been deliberately disallowed but tests with it enabled don't show any problems, and with it enabled we can again have the click event. http://github.com/appcelerator/titanium_mobile/commit/dcc312507064f1a53a2ff05919b85817c8f61aac"> http://github.com/appcelerator/titanium_mobile/commit/dcc312507064f...
(from [bad260939ab664f3777fb3239400ae266f8cc437]) [#2017 state:fixed-in-qa] Re-enable touch for WebView. It had been deliberately disallowed but tests with it enabled don't show any problems, and with it enabled we can again have the click event. http://github.com/appcelerator/titanium_mobile/commit/bad260939ab664f3777fb3239400ae266f8cc437"> http://github.com/appcelerator/titanium_mobile/commit/bad260939ab66...
1.5.0.02c264 g1 1.6 and 2.2 sim
Behavior still occurs from 1.6.2 (earliest available) - 2.0.0. WebViews do not fire click events. Works in iOS. SDK: 1.8.2 githash=59b3a90s, 2.0.0.v20120314120250 Android: V8, Rhino Studio: 2.0.0.201203121914 OS: Snow Leopard Devices Tested: GSlate 3.1, Galaxy Nexus 4.0.2 Steps to Reproduce: 1. Run code, click web view.
Expected Result: click should fire an alert Actual Result: no alert, no click eventvar win = Ti.UI.createWindow(); var webView = Ti.UI.createWebView(); webView.addEventListener('click',function(){ alert('click event fired'); }); win.add(webView); var label = Ti.UI.createLabel({ text:'click me' }); webView.add(label); win.open();PR https://github.com/appcelerator/titanium_mobile/pull/2027
Commit https://github.com/appcelerator/titanium_mobile/commit/5b5b8f13800ee9d8ab279342a53fb9f8686d1e06 s seems to have broken onclick handlers for tags within html content in Ti.UI.WebView. I have html content containing tags like these:
This works for SDK 2.0.1 GA (and 1.8.2) but fails for continurous build 2.1.0.v20120418184403. In SDK 2.0.1 GA tap on a link fires the the onclick handler as expected In SDK 2.1.0.v20120418184403 tap on a link leads to a text select action Tested on emulator with android 4.0.3. This issue should be reopened! Regards Dietrich<a onclick="Titanium.App.fireEvent('openURL', { url: this.href});return false;">linktext</a>Hi Dietrich, can you provide the whole test case? BTW, do you test it on iOS? Does iOS give you a different behavior than Android? Thanks.
@Ping Wang: In IOS this works as expected and no difference between SDK 2.0.1 GA and SDK 2.1.0.v20120418184403. Here we go with the test case:
// this sets the background color of the master UIView (when there are no windows/tab groups on it) Titanium.UI.setBackgroundColor('#000'); // create tab group var tabGroup = Titanium.UI.createTabGroup(); // // create base UI tab and root window // var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var tab1 = Titanium.UI.createTab({ icon:'KS_nav_views.png', title:'Tab 1', window:win1 }); var button1 = Titanium.UI.createButton({ title:'open webview window', width:220, height:40 }); win1.add(button1); var winwebview = Titanium.UI.createWindow({ title:'Window with webview', backgroundColor:'#fff' }); var webview = Titanium.UI.createWebView({ }); Ti.App.addEventListener('openURL', function(e){ Ti.Platform.openURL(e.url); }); winwebview.add(webview); var counter = 0; button1.addEventListener('click',function(e) { counter++; webview.html = '<h1>Counter is: ' + counter + '</h1>' + '<a href="http://www.appcelerator.com" onclick="Titanium.App.fireEvent(\'openURL\', { url: this.href});return false;">www.appcelerator.com</a>'; tab1.open(winwebview,{animated:true}); }); // // create controls tab and root window // var win2 = Titanium.UI.createWindow({ title:'Tab 2', backgroundColor:'#fff' }); var tab2 = Titanium.UI.createTab({ icon:'KS_nav_ui.png', title:'Tab 2', window:win2 }); var label2 = Titanium.UI.createLabel({ color:'#999', text:'I am Window 2', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win2.add(label2); // // add tabs // tabGroup.addTab(tab1); tabGroup.addTab(tab2); // open tab group tabGroup.open();Steps for functional test: 1) Run the test case below. Click the webview and the alert should show. 2) Comment out "webView.addEventListener(...)" and run the test case again. Click any link in the webview. It should open the link and no alert shows.
var win = Ti.UI.createWindow(); var webView = Ti.UI.createWebView({ url:"https://www.google.com/" }); webView.addEventListener('click',function(e){ alert('Click event fired. source = ' + e.source + ', x = ' + e.x + ", y = " + e.y); }); win.add(webView); win.open();Closing as Fixed. Verified via Ping's test code. SDK: 2.1.0.v20120613210250 Studio: 2.1.0.201206131907 OS: Snow Leopard Devices Tested: Android Emulator 2.3.3, Nexus One 2.2.2, Nexus S 4.0.4 Android Runtime: V8, Rhino