如果在Ubuntu手機中判斷鍵盤是否已經開啟

來源:互聯網
上載者:User

標籤:

在一些應用中我們需要判斷鍵盤是否已經出現。如果出現的話,我們有時不希望有鍵盤。我們也可以通過軟體的方法讓鍵盤消失。在這篇文章中,我們來介紹如何來實現這個。


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);        }    }}


  


在上面的例子裡,我們可以看到當鍵盤沒有啟動時:


Qt.inputMethod.visible 


為false。當鍵盤啟動後,它的值變為true。當然我們也可以通過方法:


 Qt.inputMethod.hide();

來讓鍵盤消失。



如果在Ubuntu手機中判斷鍵盤是否已經開啟

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.