How to determine whether the keyboard is enabled on an Ubuntu mobile phone?

Source: Internet
Author: User

How to determine whether the keyboard is enabled on an Ubuntu mobile phone?

In some applications, we need to determine whether the keyboard has appeared. If it appears, we sometimes don't want a keyboard. We can also remove the keyboard through software. In this article, we will introduce how to implement this.


import QtQuick 2.0import Ubuntu.Components 1.1/*!    \brief MainView with a Label and Button elements.*/MainView {    // objectName for functional testing purposes (autopilot-qt5)    objectName: "mainView"    // Note! applicationName needs to match the "name" field of the click manifest    applicationName: "inputmethod.liu-xiao-guo"    /*     This property enables the application to change orientation     when the device is rotated. The default is false.    */    //automaticOrientation: true    // Removes the old toolbar and enables new features of the new header.    useDeprecatedToolbar: false    width: units.gu(60)    height: units.gu(85)    Page {        title: i18n.tr("inputmethod")        Column {            spacing: units.gu(2)            TextField {                id: input            }            Text {                text: "Input method: " + "<b>" + Qt.inputMethod.visible + "</b>"            }            Button {                text: "Hide Input method"                onClicked: {                    Qt.inputMethod.hide();                }            }        }        Component.onCompleted: {            var keys = Object.keys(Qt.inputMethod);            for(var i = 0; i < keys.length; i++) {                var key = keys[i];                // prints all properties, signals, functions from object                console.log(key + ' : ' + Qt.inputMethod[key]);                if (key === "locale") {                    console.log("Native lang: " + Qt.inputMethod[key].nativeLanguageName);                }            }            var rect = Qt.inputMethod.keyboardRectangle;            console.log("keyboard size: " + rect.width + " " + rect.height);        }    }}



In the above example, we can see that when the keyboard is not started:


Qt. inputMethod. visible


Is false. When the keyboard is started, its value changes to true. Of course, we can also use the following methods:


 Qt.inputMethod.hide();

To make the keyboard disappear.


Details

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.