omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Remove focus from text field/resign keyboard

    Pythonista
    2
    4
    3828
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jonstieg
      Jonstieg last edited by

      I have a UI with three text fields and one button. All three text fields use the Number Pad keyboard, which don't have a Return key to hide the keyboard.
      What I'm looking for is that when I tap the button, the text field that has the focus (one always does), loses focus. I don't know which text field will have the focus when the button is tapped.
      All the text field implement delegates.

      My first thought was to send a simulated return key with the button tap, but I couldn't figure out how to do this. I tried the textfielf.end-editing() with a couple of different delegate methods, but it didn't work.

      Can anybody suggest a way to remove the focus from a text field?
      Thanks

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        See http://omz-forums.appspot.com/pythonista/post/6456855224123392

        Using delegate.textfield_should_begin_editing() or delegate.textfield_did_begin_editing() you should be able to keep track of which of the three fields has the focus. When the button in tapped, you could call textfield.begin_editing() on one of the two other textfields.

        1 Reply Last reply Reply Quote 0
        • Jonstieg
          Jonstieg last edited by

          That's a very slick solution. I actually made a dummy text field, hid it behind another field, and set the focus to that on button press.

          Thanks so much. I push this app on people like a drug dealer. I love it.

          1 Reply Last reply Reply Quote 0
          • ccc
            ccc last edited by

            You can hide your dummy text field by setting its height and/or width to zero.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors