Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20560] Android: A button will fire an event listener for the button and the window

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2017-05-03T12:23:29.000+0000
Affected Version/sRelease 5.2.1
Fix Version/sn/a
ComponentsAndroid
Labelsqe-5.2.1
ReporterJosh Longton
AssigneeGary Mathews
Created2016-03-11T23:45:41.000+0000
Updated2018-08-06T17:37:01.000+0000

Description

A button will fire an event listener for the button and the window *Steps to reproduce:*

Use the app.js bellow

*Actual :* Both events are fired when the button is clicked *Expected:* Only the button event is fired when the button is clicked and only the window event is fired when the window is clicked *App.js:*
var window = Ti.UI.createWindow();
var button = Titanium.UI.createButton({title: 'click'});

	window.add(button);

button.addEventListener('click', function() {
	// alert('Button');
	window.close();
});
	
window.addEventListener('click', function() {
	
	// alert('Window');
        Titanium.Media.openPhotoGallery({

            success: function(event) {
                alert('success');
            },
            cancel: function(cancel) {
                alert('cancel');
            },
            error: function(error) {
                alert('error');
            }
        });
    });
     window.open();

Comments

  1. Gary Mathews 2017-05-03

    [~jlongton] This is expected behaviour (http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Proxy-property-bubbleParent) "Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window." And can be controlled by bubbleParent
       var win = Ti.UI.createWindow(),
           btn = Titanium.UI.createButton({
               title: 'BUTTON',
               bubbleParent: false
           });
       
       btn.addEventListener('click', function() {
       	alert('button');
       });
       
       win.addEventListener('click', function() {
       	alert('window');
       });
       
       win.add(btn);
       win.open();
       
  2. Eric Merriman 2018-08-06

    Closing as invalid. If incorrect, please reopen.

JSON Source