Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9124] Android: window blur event it's not triggered when going back to the parent window

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2012-05-23T15:26:51.000+0000
Affected Version/sRelease 1.7.6, Release 2.1.0, Release 1.8.2, Release 2.0.1
Fix Version/sn/a
ComponentsAndroid
LabelsSupportTeam, api, parity
ReporterFederico Casali
AssigneeHieu Pham
Created2012-05-14T09:10:33.000+0000
Updated2017-03-21T22:40:25.000+0000

Description

Problem description

Blur eventListener is set in the parent window and it's correctly triggered when opening the window. Moving back from a child window to the parent window does not trigger the blur event. This happens both for heavyweight and lightweight children window from 1.8.2 SDK. On 1.7.6 it is correctly triggered only if the child window is a heavyweight.

Customer engagement notes

With the same code on iOS, blur event it's always triggered. ING will be using Lightweight windows inside a tabGroup and need to have the same behavior, using same code, between iOS and Android. This is blocking issue for the customer.

Code to reproduce

Using the sample code below, button in win1 opens a Lightweight child window (win3). When win3 it's closed, focus event it's not triggered using all SDK versions. Uncomment line 36 (fullscreen:false) in order to make 'win3' heavyweight. When win3 it's closed, focus event it's triggered only using SDK 1.7.6. With any other higher version it's not.
// 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
});

win1.addEventListener('focus', function(){
	alert('focused!')
});



var button = Ti.UI.createButton({
	title:'open win3',
	width:200,
	height:100
});
button.addEventListener('click', function(){
	var win3 = Ti.UI.createWindow({
		title:'foobar',
		backgroundColor:'blue',
		// fullscreen:false
	});
	var button2 = Ti.UI.createButton({
		title:'back to win1',
		width:200,
		height:100,
		backgroundColor:'white'
	});
	button2.addEventListener('click', function(){
		win3.close()
	});
	win3.add(button2);
	win3.addEventListener('blur', function(){
        Ti.API.info("WIN3 BLURRED");
    });

	win3.open();
});

win1.add(button);


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);


tabGroup.addTab(tab1);  
tabGroup.addTab(tab2);  

tabGroup.open();

Comments

  1. Mauro Parra-Miranda 2012-05-15

    This is looking good when moving between tabs, but when using this example:
       
       var win = Ti.UI.createWindow({backgroundColor:'white'});
       var label = Ti.UI.createLabel({
       	text:'Click me',
       });
       var win2 = Ti.UI.createWindow({backgroundColor:'white'});
       label.addEventListener('click',function(){
       	win2.open();
       });
       win.addEventListener('blur',function(){
       	alert('blur from win1');
       });
       var label2 = Ti.UI.createLabel({
       	text:'close me'
       });
       win2.add(label2);
       label2.addEventListener('click',function(){
       	win2.close();
       });
       win.add(label);
       win.open();
       
    this differs from the behavior in android and ios
  2. Hieu Pham 2012-05-15

    Hey Mauro, The fix for 8976 and 9124 is temporary, and somewhat incomplete. It should work well with tabgroup as all tabs are HW windows, but doesn't work with this scenario: LW parent -> LW child (which is the one in the sample code). A more permanent fix is currently on its way.
  3. Hieu Pham 2012-05-15

    Tested with master and verified that the fix for timob-8976 fixes this issue for tabgroup. Closing as unable to reproduce.
  4. Neeraj Gupta 2012-05-22

    Duplicate of TIMOB-8976.
  5. Mauro Parra-Miranda 2012-05-23

    This is the blur, the other one is the focus. If you guys, we can just unify this to one bug, but they are different issues. Best, Mauro
  6. Hieu Pham 2012-05-23

    This should be fixed along with timob-8976
  7. Mauro Parra-Miranda 2012-05-23

    Tested again, confirmed as fixed in the latest CI build.
  8. Lee Morris 2017-03-21

    Closing ticket as duplicate.

JSON Source