daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Feb 11th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var textfield = Ti.UI.createTextfield();
  2. textfield.addEventListener('android:back', function() {
  3.   // this method is never called, so this event does not run on textfield
  4. });
  5.  
  6. textfield.addEventListener('focus', function() {
  7.   // this method is called at step 1
  8. });
  9.  
  10. textfield.addEventListener('blur', function() {
  11.   // this method is not called at step 2 because
  12.   // the back button only hide the keyboard but the focus is not lost
  13. });
  14.  
  15. // what code should I use to catch event when the keyboard is hidden
  16. // when pressing the back button ?
  17.    
  18. textField.addEventListener('blur', function(e) {
  19.     var val = e.value; // Get current value when the keyboard closed (the right way) as opposed to textField.value (the wrong way)
  20.     alert("The text is : "+value);
  21. });
  22.    
  23. var win = Ti.UI.currentWindow;
  24. win.addEventListener('android:back', function(e) {
  25.     // do crazy things
  26. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top