Titanium Community Questions & Answer Archive

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

How to hide Keyboard

Hi, I'm new to Titanium and i'm tryin to create a calculator app for my own use. The problem is, that none of the default apple keyboards have the buttons i need, so i'm trying to make a custom keyboard layout with single buttons. My Question is now, how can i hide the keyboard though I focus a textfield (to have this blinking bar which indicates a selected textfield). Its not working with blur cause then the bar disappears/field is not selected. How can i block the keyboard while still focusing the active textfield?

— asked November 23rd 2010 by Linus Lehnert
  • block
  • calculator
  • custom
  • focus
  • hide
  • keyboard
  • layout
  • textfield

5 Answers

  • TextField.blur(); will hide the keyboard.

    Example below is an event listener for the DONE button. When the button is clicked, the keyboard disappears.


    — answered June 9th 2011 by s c
    • just because this is bound to trip someone up: in this case TextField.blur(); (which works) is not equivalent to TextField.fireEvent('blur'); (which doesn't work)

      Mind you, it should be. It's supposed to be. But in one of those random bugs that you get used to after the first few hours with Titanium, it ain't.

      — commented February 20th 2012 by Paul Degnan
    • I just read this comment – it's old, but I wanted to correct it in case anybody else sees this. TextField.fireEvent('blur') is not supposed to be the same as TextField.blur().

      Firing the event will call all the registered event listeners for the blur event. It doesn't actually change the focus of the field.

      Just like calling TextField.fireEvent('change') is not the same as TextField.setValue('foo');

      — commented October 3rd 2014 by Jason Priebe
  • enabled: false
    works for ios

    check this link


    — answered September 25th 2012 by SWAR M
  • This guy here has an alternative approach. Check him out.

    — answered July 7th 2012 by Jonah Mancini
  • I need the same: In particular I need to be able to allow the text in a TextField to be copyable so that it can be pasted elsewhere. But the text is not to be editable, so the keyboard is not wanted/needed.

    I think by setting the TextField.editable to false and .enabled to true should tell the keyboard not to pop up and allow other text functions (like copy / paste) to function.

    — answered September 26th 2013 by Brian Burgess
    1 Comment
    • Hey I just found that the TextArea works as I describe above .. but the TextField does not .. any find this? .. or a way around it? .. Perhaps just use TextArea for everything?

      — commented September 26th 2013 by Brian Burgess
  • Why not have a look in the Kitchen sink for an answer?


    — answered November 23rd 2010 by Chris Johnson
    • I'm sorry but i couldn't find anything in the Kitchen sink, i checked before i posted my question here. Could you maybe tell me at which one i have to look exactly? Didn't mention yet but the app should mostly be for iPhone devices.

      — commented November 24th 2010 by Linus Lehnert
    • Hi Linus,

      Your question is very common but no one has the answer.

      Why can't I hide the Keyboard in the iPhone?
      Your question is simple and easy. Your description of the problem is clear (I'm a spaniard and my english is terrible and I understand it very well).

      "Why not have a look in the Kitchen sink for the answer?" I think Cris NEVER executes the Kitchen Sink in iPhone. Why the people answer a question with another question? Because they are trolls.

      Sorry, but I'm very tired with the people witch only writes stupidities to a serious questions.

      If you finally find the answer, please publish it. I'm looking for it too and I'm working on it.

      — commented February 24th 2011 by Jose Juan Calvo Espinosa
    • Man, some people try to help with no answer in mind. This is a question that I'm looking for to, and if I find I will publish. A bit more about kitchen sink, it is full of crap and the documentation is incompleted.

      — commented March 11th 2011 by Daniel Colnaghi
    • Just in the textfield make the property as enabled : false. Then the keyboard wont show up.

      — commented June 9th 2011 by Manu ranjan
    • Manu, which property do you set to false ?

      — commented June 9th 2011 by s c
    • set textfield property editable as false.

      — commented June 6th 2012 by Rahul Gharat
    • I constructed my app with wrappers for the components in Ti. In my textfield/textarea wrapper, I make sure that whoever is using it passes the window instance, that way I can add a click event and blur all the fields that were added to this window. Of course just make sure you add the event once and only for IOS hope this helps

      — commented May 17th 2013 by Mobile Developer
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.