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!
2 Answers
Accepted Answer
Hi Matt,
Try this code that may help you.Best luck
textField.addEventListerner('return',funtion(e){ textField.blur(); });
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!