Skip to content

Instantly share code, notes, and snippets.

@MotiurRahman
Created December 20, 2019 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MotiurRahman/b543160fea42d8a888900bfb5cea692f to your computer and use it in GitHub Desktop.
Save MotiurRahman/b543160fea42d8a888900bfb5cea692f to your computer and use it in GitHub Desktop.
Focus Test
var win = Ti.UI.createWindow({
title : "Focus Test",
backgroundColor : 'red',
layout : "vertical"
});
// Create a TextField.
var aTextField = Ti.UI.createTextField({
height : 40,
top : 30,
left : 20,
right : 20,
backgroundColor : "gray",
hintText : 'This is hint text',
softKeyboardOnFocus : Ti.UI.Android.SOFT_KEYBOARD_DEFAULT_ON_FOCUS, // Android only
keyboardType : Ti.UI.KEYBOARD_DEFAULT,
returnKeyType : Ti.UI.RETURNKEY_DEFAULT,
borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED
});
// Listen for return events.
aTextField.addEventListener('return', function(e) {
aTextField.blur();
alert('Input was: ' + aTextField.value);
});
// Add to the parent view.
win.add(aTextField);
// Create a Button.
var test = Ti.UI.createButton({
title : 'Focus Test',
height : Ti.UI.SIZE,
width : Ti.UI.SIZE,
top : 50,
});
// Listen for click events.
test.addEventListener('click', function() {
aTextField.focus();
//alert('\'aButton\' was clicked!');
});
// Add to the parent view.
win.add(test);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment