Cannot Scroll to Buttons View - Blocked by Keyboard

You must Login before you can answer or comment on any questions.

I have placed two buttons below a tableView for iOS and ran into an issue while testing. For some reason when I click a textField in the table the buttons disappear behind the keyboard and I cannot scroll past the table to view the buttons nor can I find a way to close the keyboard. I understand that I can use textField.blur() to hide the keyboard on a listener, but I don't which eventListener to use to hide the keyboard since there is nowhere else to click -- the only thing in the viewport is the table and the keyboard.

I have included some sample code below to exemplify what I am talking about, but basically I would like a way to either hide the keyboard or find a way to scroll past the table to the buttons which the user would click to continue.

The code below creates the table & the buttons and then adds them to the currentWindow. I add the two buttons separately to the window since for some reason the footerViewButtons view doesn't actually work for me.

function addRow(hintName)
{
   row = Ti.UI.createTableViewRow({height:45, left:0});
 
    textField = Titanium.UI.createTextField({
        //font:{fontSize:18, fontWeight:'bold'},
        textAlign: 'left',
        left: 7,
        width:100,
        hintText:hintName,
        keyboardType:Titanium.UI.KEYBOARD_NUMBER_PAD,
        borderStyle:Titanium.UI.INPUT_BORDERSTYLE_NONE
    });
 
    textFieldsArray[hintName] = textField;
 
    row.add(textField);
    row.selectionStyle = Ti.UI.iPhone.TableViewCellSelectionStyle.NONE;
    return row;
}
 
calcButton = Ti.UI.createButton({
    font:{fontSize:17, fontWeight:'bold'},
    height: 45,
    width: '45%',
    left: 10,
    bottom: 85,
    title: 'Calculate'
});
 
resetButton = Ti.UI.createButton({
    font:{fontSize:17, fontWeight:'bold'},
    height: 45,
    width: '45%',
    right: 10,
    bottom: 85,
    title: 'Reset'
});
 
footerViewButtons = Ti.UI.createView({});
footerViewButtons.add(calcButton);
footerViewButtons.add(resetButton);
 
 
otherdata = [];
    otherdata[0] = Ti.UI.createTableViewSection({ headerTitle: 'Nutrition Info' });
    otherdata[1] = addRow('Field 1');
    otherdata[2] = addRow('Field 2');
    otherdata[3] = addRow('Field 3');
    otherdata[4] = addRow('Field 4');
 
 
    tableView = Ti.UI.createTableView({
      data: otherdata,
      style: Titanium.UI.iPhone.TableViewStyle.GROUPED,
    });
 
 
win.add(tableView);
win.add(calcButton);
win.add(resetButton);
Thank you in advance!

— asked 1 year ago by Matt Donders
1 Comment
  • Have you solve your problem or not?.

    — commented 1 year ago by Nitin Chavda

2 Answers

Accepted Answer

Hi Matt,

Try this code that may help you.Best luck

textField.addEventListerner('return',funtion(e){
textField.blur();
});

— answered 1 year ago by Nitin Chavda
answer permalink
4 Comments
  • If I used the 'return' eventListener, would that require me to use the normal keyboard? Currently I am using the Titanium.UI.KEYBOARD_NUMBER_PAD keypad so the user can only type numbers into the fields. Is there a number pad with a return key or something similar to that?

    — commented 1 year ago by Matt Donders

  • Hi Matt,

    You can use this for alternate of your keyboard type.

    returnKeyType : Titanium.UI.RETURNKEY_RETURN,
    keyboardType : Titanium.UI.KEYBOARD_NUMBERS_PUNCTUATION,
    and for only number input you can use this one.
    textField.addEventListener('change', function(e) {
        textField.value = textField.value.replace(/[^0-9]+/, "");
    });
    textField.addEventListener('return', function(e) {
        textField.blur();
    });

    — commented 1 year ago by Nitin Chavda

  • This was my best option - I just used the replace function, thank you!

    — commented 1 year ago by Matt Donders

  • Show 1 more comment

hi Matt, there is no option for Number_Pad keyboard to hide but you can do like this

var cancel = Titanium.UI.createButton({
    title : 'Cancel'
});
 
cancel.addEventListener('click', function(e) {
    textField.blur();
});
 
var flexSpace = Titanium.UI.createButton({
    systemButton : Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});
var btn = Ti.UI.createButton({
    title : 'Done'
});
 
btn.addEventListener('click', function(e) {
    textField.blur();
});
 
var textField = Titanium.UI.createTextField({
    //font:{fontSize:18, fontWeight:'bold'},
    textAlign : 'left',
    left : 7,
    width : 100,
    height : 40,
    keyboardToolbar : [cancel, flexSpace, btn],
    keyboardType : Titanium.UI.KEYBOARD_NUMBER_PAD,
    borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
 
win.add(textField);

Your Answer

Think you can help? Login to answer this question!