4
votes

Is there a way to hide the language selection key from the virtual keyboard without use a custom layout?

enter image description here

3
I'm not familiar with the virtual keyboard but this sounds like a custom layout. If keyboard supports changing layouts, you should be able to hide it. I really doubt that it supports hiding specific keys.rbaleksandar

3 Answers

3
votes

I was able to hide the language key with a workaround:

    property var keyboardLayout: inputPanel.keyboard.layout


    function findChildByProperty(parent, propertyName, propertyValue, compareCb) {
        var obj = null
        if (parent === null)
            return null
        var children = parent.children
        for (var i = 0; i < children.length; i++) {
            obj = children[i]
            if (obj.hasOwnProperty(propertyName)) {
                if (compareCb !== null) {
                    if (compareCb(obj[propertyName], propertyValue))
                        break
                } else if (obj[propertyName] === propertyValue) {
                    break
                }
            }
            obj = findChildByProperty(obj, propertyName, propertyValue, compareCb)
            if (obj)
                break
        }
        return obj
    }



    onKeyboardLayoutChanged: {
        if(keyboardLayout!=""){
            var ChangeLanguageKey= findChildByProperty(inputPanel.keyboard, "objectName", "changeLanguageKey", null)
            if(ChangeLanguageKey){
                ChangeLanguageKey.visible=false
            }
        }
    }


    InputPanel {
        id: inputPanel
        z: 99
        y: parent.height
        anchors.left: parent.left
        anchors.right: parent.right




        states: State {
            name: "visible"

            when: inputPanel.active
            PropertyChanges {
                target: inputPanel
                y: parent.height - inputPanel.height
            }
        }
        transitions: Transition {
            from: ""
            to: "visible"
            reversible: true
            ParallelAnimation {
                NumberAnimation {
                    properties: "y"
                    duration: 400
                    easing.type: Easing.InOutBack
                }
            }
        }





        CustomComponents.AutoScroller {

            id:autoscroller

            panelY: inputPanel.y
        }


    }

enter image description here

This only works in version 5.9 where the objectname property is defined with "changeLanguageKey", for previous versions set the property in the source code and recompile.

1
votes

No, not without using a custom layout.

You can always modify the layouts that come with the keyboard though.

1
votes

I was able to hide the hideKeyboard key with this trick. I basically tried to get the reference of the emoji key and thereby was able to disable the next key which is hideKeyboard key.

function disableKey(parent, objectText) 
{

   var obj = null
   if (parent === null)
        return null
   var children = parent.children       
   for (var i = 0; i < children.length; i++) {
       obj = children[i]
       if (obj.text === objectText && obj.toString().substring(0, 7) === "BaseKey") {
           console.log("Disabling symbols. " + obj.text)
           obj.enabled = false
       }
       else if(obj.displayText === "HWR"){
            console.log("Disabling Handwriting mode button." + obj.displayText + " " + objectText)
            obj.visible = false
       }          
       else if(obj.text === ":-)" && obj.toString().substring(0, 7) === "BaseKey"){
           console.log("Disabling hidekeyboard key." + obj.text)
           children[i+1].visible = false
       } 
   obj = disableKey(obj, objectText)
       if (obj)
           break
   }
   return obj
}