Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8846] Android: Ti.UI.TextArea doesn't fire events properly

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2012-04-25T16:28:29.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sn/a
ComponentsAndroid
Labelsapi, parity
ReporterJunaid Younus
AssigneePing Wang
Created2012-04-20T11:45:29.000+0000
Updated2017-03-24T18:12:15.000+0000

Description

*Code*
var win = Ti.UI.createWindow({
	backgroundColor: 'white'
});

var button = Ti.UI.createButton({
	title: 'Press me!',
	width: 300,
	height: 40
});

button.addEventListener('click', function(e)
{
	var win2 = Ti.UI.createWindow({
		backgroundColor: 'yellow',
		fullscreen: false
	});
	
	var textArea = Ti.UI.createTextArea({
		height: 50,
		left: 20,
		right: 20,
		top: 50,
		isFocused: false // custom property to keep track of current state
	});
	textArea.addEventListener('focus', function(e)
	{
		Ti.API.info('textArea has been focused.');
		textArea.isFocused = true;
	});
	textArea.addEventListener('blur', function(e)
	{
		Ti.API.info('textArea has been blurred.');
		textArea.isFocused = false;
	});
	
	win2.addEventListener('android:back', function(e)
	{
		if (textArea.isFocused)
			textArea.blur();
		else 
			win2.close();
	});
	
	win2.add(textArea);
	win2.open();
});

win.add(button);
win.open();

*Expected behavior* When you run the app, press the button. When you tap on the Ti.UI.TextArea object, ddms should print out that it has been focused. When you tap the back button, it should hide the keyboard and print out that is has been blurred. When you repeat this once again, the same should happen. Now if you tap the back button once more, it should close the yellow window and return to the first window. *Summarized steps for expected behavior* 1. Open app, press the button, check ddms -> no output. 2. Tap on the text area, check ddms -> output: text area focused. 3. Press the back button, check ddms -> output: text area blurred. 4. Tap on text area again, check ddms -> output: text area focused. 5. Press back button again, window should NOT close, check ddms -> output: text area blurred. 6. Tap back button again -> window should close. *Actual behavior* When you run the app and press the button, the keyboard is NOT shown but ddms prints out that the Ti.UI.TextArea object has been focused. When you tap on the object, the keyboard not shows and not new events have been fired. When you tap on the back button, ddms prints out that the text area has been focused and blurred (2 print outs). If you tap on the object again to focus, NO new output is shown in ddms. If you now tap the back button, ddms prints out that the text area has been blurred AND it also closes the window. *Summarized steps to reproduce current issue (HTC Sensation 4G)* 1. Open app, press the button, check ddms -> output: text area focused. 2. Tap on the text area, check ddms -> no output. 3. Press the back button, check ddms -> output: text area focused AND output: text area blurred. 4. Tap on text area again, check ddms -> no output. 5. Press back button again, window has been closed, check ddms -> output: text area blurred. *Notes* -Only tested on a HTC Sensation 4G and LG Optimus. -Both devices have different actual behaviors, however both of them are NOT the expected behavior. -When run on the iOS simulator, the focus and blur events are printed out correctly (obviously the 'android:back' events doesn't work on iOS, so it's working as expected). -Possible feature in the future: would be nice if the Ti.UI.TextArea object would expose a property of its current state (i.e. if it's currently focused or blurred).

Comments

  1. Vishal Duggal 2012-04-25

    Marking bug as invalid because the behavior described as an error is the default android OS behavior. Also the android:back listener in the test case is useless as the app will behave the same way even without the listener added.
  2. Lee Morris 2017-03-24

    Closing ticket as invalid with reference to the above comments.

JSON Source