What is the correct way of dismissing the keyboard in a ui::TextField?

In 3.1, I have a ui::TextField. I also have a button that dismisses the keyboard added to the scene. Reading the code in the text field class leads me to believe I should call setDetachWithIME. However, this does not work. Instead I use textField->didNotSelectSelf(). This doesn’t seem right, but maybe it’s the way a keyboard needs to be dismissed?

1 Like

@Javy

You should get the render and call its closeIME method, please refer to the following code snippets:

 TextField* textField = dynamic_cast<TextField*>(pSender);
 UICCTextField *ime = dynamic_cast<UICCTextField*>(textField->getVirtualRenderer());
  ime->closeIME();
1 Like

It should have an easier method call, such as textField->hideKeyboard(); or similar.

Thanks for the clear answer.

Agreed. Just ran into this today and it’s certainly not an obvious way of closing the IME! Regardless, thanks to owen for the answer. Works for me.

This code worked like a charm, it’s still the best way in 2019.