5

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

enter image description here

Rui Sebastião
  • 855
  • 1
  • 18
  • 36
  • 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 Mar 16 '17 at 12:30

3 Answers3

3

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.

Rui Sebastião
  • 855
  • 1
  • 18
  • 36
  • This works great but unfortunately the hideKeyboardKey doesn't have an object name or a property that I can reference. Any idea's on how to get rid of it? I imported a custom style so I can set it's enabled property to false but the layout doesn't adjust itself if you do it that way :( I feel like they should have integrated a simple method for doing this into the keyboard. – Rob Sep 16 '19 at 18:30
1

No, not without using a custom layout.

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

Mitch
  • 23,716
  • 9
  • 83
  • 122
1

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
}