[TIMOB-27700] Problem with textField.focus()
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Michael Landeck |
Assignee | Unknown |
Created | 2019-11-12T10:01:13.000+0000 |
Updated | 2019-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();
No comments