Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27700] Problem with textField.focus()

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterMichael Landeck
AssigneeUnknown
Created2019-11-12T10:01:13.000+0000
Updated2019-12-26T17:33:23.000+0000

Description

The textField.focus function does not work if you call in an event, like the open event of a window, if you call on a button-click-event it works. I want that the inputField keeps the focus after the user hits the returnkey, so that he can type in the next value immediately, without touching the textField first. It was not a problem in SDKs < 8.00. Example:
    var win = Ti.UI.createWindow({
        backgroundColor : '#DCDCDC'
    });
    var aButton = Titanium.UI.createButton({
	   title: 'Focus textField',
       top:100,
       left:320,
       width: 300,
	});
	aButton.addEventListener('click', function() {
	    inputField.focus();  // works
	});
    var inputField = Titanium.UI.createTextField({
		top : 100,
		width:200,
		left : 100,
      	height:30,
      	backgroundColor:'white',
	  	returnKeyType : Titanium.UI.RETURNKEY_DONE,
	});
	inputField.addEventListener('return', function(_e) {
  		Ti.API.info("return");
  	    _e.source.value = '';
    	_e.source.focus();
  	});
	inputField.addEventListener('focus', function(e) {
		Ti.API.info("focus");
	});
    win.add(aButton);
    win.add(inputField);
    inputField.focus(); // doesn't work
    win.open();

Comments

No comments

JSON Source