Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2017] Android: WebView No Longer Fires Click Event

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-04-23T12:58:38.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0, Release 2.1.0, Sprint 2012-08
ComponentsAndroid
Labelsandroid, api, defect, module_webview, qe-testadded, regression
ReporterDon Thorp
AssigneePing Wang
Created2011-04-15T03:08:13.000+0000
Updated2012-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

FileDateSize
app.js2011-04-15T03:08:14.000+00001194
index.html2011-04-15T03:08:14.000+0000774

Comments

  1. Bill Dawson 2011-04-15

    i'm working on tests for this

  2. Bill Dawson 2011-04-15

    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

  3. Bill Dawson 2011-04-15

    (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...

  4. Bill Dawson 2011-04-15

    (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...

  5. Thomas Huelbert 2011-04-15

    1.5.0.02c264 g1 1.6 and 2.2 sim

  6. Dustin Hyde 2012-03-14

    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.
       var 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();
       
    Expected Result: click should fire an alert Actual Result: no alert, no click event
  7. Ping Wang 2012-04-17

    PR https://github.com/appcelerator/titanium_mobile/pull/2027
  8. Dietrich Streifert 2012-04-19

    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:
       <a onclick="Titanium.App.fireEvent('openURL', { url: this.href});return false;">linktext</a>
       
    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
  9. Ping Wang 2012-04-19

    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.
  10. Dietrich Streifert 2012-04-20

    @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();
        
  11. Ping Wang 2012-04-20

    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();
        
  12. Dustin Hyde 2012-06-14

    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

JSON Source