Making the Jolla/Sailfish OS virtual keyboard hide when you press return

Whilst programming an app on my Jolla phone I discovered that the
virtual keyboard wouldn’t disappear when the return button is pressed.
What is even more frustrating is that I couldn’t find on Google easily
how to solve this problem.

 

It turns out there is a generic way to access input controls in QT.

Qt.inputMethod

In the case of a Jolla phone (or a Sailfish OS device) this object
controls the virtual keyboard.

The way to get the ‘Return’ key trigger the removal of the virtual
keyboard is done as follows:

Keys.onReturnPressed: { Qt.inputMethod.hide() }

Leave a Reply

Your email address will not be published. Required fields are marked *