Use the following code to hide and show the iOS keyboard and toolbar when using the keyboard toolbar buttons.
Last active
May 18, 2017 09:35
-
-
Save brentonhouse/2ffd923d41632d29bbd45c5516751d76 to your computer and use it in GitHub Desktop.
Hide/Show iOS keyboard w/ Appcelerator Alloy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hideKeyboard = function(e) { | |
var parent_name = e.source.textField; | |
if(parent_name) { | |
var parent = $[parent_name]; | |
parent.blur(); | |
parent.keyboardToolbar.visible = false; | |
} | |
}; | |
var showKeyboard = function(e) { | |
e.source.keyboardToolbar.visible = true; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<TextField id="myTextField" width="Ti.UI.FILL" textAlign="Titanium.UI.TEXT_ALIGNMENT_RIGHT" keyboardType="Ti.UI.KEYBOARD_TYPE_DECIMAL_PAD" verticalAlign="Ti.UI.TEXT_VERTICAL_ALIGNMENT_CENTER" onFocus="showKeyboard"> | |
<KeyboardToolbar> | |
<Toolbar> | |
<Items> | |
<Button systemButton="FLEXIBLE_SPACE" /> | |
<Button systemButton="DONE" onClick="hideKeyboard" textField="myTextField" /> | |
</Items> | |
</Toolbar> | |
</KeyboardToolbar> | |
</TextField> | |
</Alloy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment