Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Prevent the Keyboard from hiding AND keyboard covering text fields

I have a twofer.

First, I have a text field that pops up the keyboard when it goes into focus. Great. Then when the user hits enter on the keyboard, it jumps to another text field. The problem is that the keyboard drops down when the first field goes out of focus and pops back up when the second field comes into focus. Is there any way just to prevent it from being dismissed in the first place?

Second, I have a problem with a TableView not scrolling properly. When my text field goes into focus, the TableView should scroll so that it doesn't cover the text field. The first time the text field is selected, it does this as it should. But subsequently it doesn't scroll properly so it's possible that the keyboard will cover the text field. Any ideas how to fix this?

Thanks

Reed

— asked November 18th 2010 by Reed Abbott
  • keyboard
  • tableview
  • textfield
0 Comments

3 Answers

  • If I read the first part correctly, I think I can help. On my form, I place all the components on a child view of the main window. On the focus() or blur() of each text field (which triggers the keyboard), I move the whole view like the following:

    var oldTop = 25;
    var newTop = viewMain.top - 40;
    
    // SLIDE SCREEN UP WHEN ENTERING TITLE
    titleField.addEventListener('focus', function(){
      viewMain.top = newTop;
    });
    
    // SLIDE SCREEN BACK TO ORIGINAL POSITION
    titleField.addEventListener('blur', function(){
      viewMain.top = oldTop;
    });
    

    I do this for each field for now. But I think it could be made into one function that takes a field object as a parameter. I just haven't figured out how to do that, yet. One caveat, I haven't tested this on Android, only iOS.

    Also, on each text field I add this property: returnKeyType:Titanium.UI.RETURNKEY_NEXT. That takes care of my return key issues.

    Hope that helps.

    — answered August 9th 2011 by Michael Stelly
    permalink
    0 Comments
  • even ive suffered from the same problem and the only solution i got ie…

    set the bottom of your tableView instead of its height,it will scroll automatically on the appearance of keyboard.

    — answered November 8th 2011 by Gagan Tiwari
    permalink
    0 Comments
  • Place the form in a ScrollView. That way the user can move the form up to access the form fields.

    — answered March 10th 2014 by George Palframan
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.