0

I have the following Virtual Keyboard which sets the y of a flickable to a value to not hide text. the settings variable is containts the IntSettingsRow below.

//Administration.qml
K_VirtualKeyBoard{
    id: keyboard
    z:100
    onVisibleChanged: {
        if(visible){
            if(settings.posY - keyboard.height > 0){
                flickable.contentY = settings.posY - keyboard.height + 20
            }
            else{
                flickable.contentY = 0
            }
        }
        if(!visible){
            settings.settingsRow.textField.focus = false
            flickable.contentY = 0
        }                      
    }
}

And i have a IntSettingsRow which is a Textfield to insert Some text.

//GeneralSettings.qml
    IntSettingsRow{
        id: touchDeactivationTimedTime
        height: itemHeight
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.topMargin: 8
        validator:  IntValidator{bottom: 10; top: 300}
        title: qsTr("deactivate time")+":"
        value: currentSettings?currentSettings.deactivationTime:0
        onValueChanged:{
            var val = parseInt(value)
            if (!isNaN(val)){
                currentSettings?currentSettings.deactivationTime = val:{}
            }
        }
        onEditingFinished: {
            if (value === "") textField.text = currentSettings.deactivationTime
        }

        onFocusChanged: {
            settingsRow = touchDeactivationTimedTime
            if(!textField.focus){
                editingFinished()
                posY = 0
            }else{
                posY = mapToItem(parent, x, y).y
            }
        }
    }

Somehow on the first click into the Textfield the virtual keyboard pops up as expected and the flickable shifts. i hide the keyboard and try it again it doesn't work. So the virtual keyboard pops up but the flickable does not change.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
tscheppe
  • 588
  • 5
  • 18

1 Answers1

0

I found a solution with editing the flickable directly from the onfocus in my intsettingsrow. now it works

So i changed my K_VirtualKeyboard to:

K_VirtualKeyBoard{
    id: keyboard
    z:100
    onVisibleChanged: {
        if(!visible){
            flickable.contentY = 0
        }
    }
}

And added this to the textfield that triggered the Keyboard

    textField.onReleased: {
        var keyBoardY
        if(keyboard.visible)
            keyBoardY = keyboard.y
        else
            keyBoardY = keyboard.y - keyboard.height
        if(keyBoardY < (mapToItem(root.parent.parent,0,0).y + height*2))
            flickable.contentY = (mapToItem(root.parent.parent,0,0).y + height*2) - keyBoardY + 8
    }
tscheppe
  • 588
  • 5
  • 18