Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Focusing TextInput doesn't open the virtual keyboard
Forum Updated to NodeBB v4.3 + New Features

Focusing TextInput doesn't open the virtual keyboard

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 52 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MarNem
    wrote last edited by
    #1

    Hi! I have a problem with windows keyboard not showing up when expected.

    I am trying to create custom text input element based on TexInput. The input should get active focus when I press / tap on other areas of my custom element (like prefix or suffix), not only on the TextInput itself. And accordingly, I'd like the windows keyboard to appear when my app is displayed on the touchscreen.

    When I run the example below: I tap in the top rectangle in the column, the keyboard doesn't popup. The same for the second rectangle: independent on where I tap - suffix, TextInput, or prefix - the keyboard doesn't pop up.
    The order in which I tap those Rectangles doesn't matter - the keyboard doesn't appear.

    Now, If in both my Rectangles I use TextField instead of TextInput: I tap on the first rectangle: keyboard appears (not on the same screen as the application, but at least it pops up). I close the app, open it again and tap on second Rectangle's prefix or suffix: keyboard doesn't appear. If I tap on the TextField itself - it does appear (again, on the wrong screen though).

    So, my questions are:

    1. Why doesn't it work with TextInput ? (I really need to use TextInput, NOT TextField)
    2. If there is a way to make it work with TextInput, how to make it work so that the keyboard pops up even when I tap in suffix / prefix?

    Thank you.

    Column {
            Rectangle { 
                color: "transparent"
                border.color: "gray"
                border.width: 1
                radius: 4
                width: 500
                height: 70
                TextInput {
                    id: textField
                    anchors.fill: parent
                    anchors.leftMargin: 10
                    anchors.rightMargin: 10
                }
            }
    
            Rectangle { // my custom element
                color: "transparent"
                border.color: "gray"
                border.width: 1
                radius: 4
                width: 500
                height: 70
    
                MouseArea {
                    anchors.fill: parent
                    hoverEnabled: true
                    onPressed: { textInp.focus = true; textInp.forceActiveFocus()}
                }
    
                RowLayout {
                    anchors.fill: parent
                    spacing: 10
                    Rectangle { // prefix area
                        color: "lightgray"
                        Layout.minimumWidth: 50
                        Layout.maximumWidth: 50
                        Layout.preferredWidth: 50
                        height: parent.height
                        radius: 4
                        border.color: "gray"
                        border.width: 1
                    }
                    TextInput {
                        id: textInp
                        height: parent.height
                        Layout.fillWidth: true
                    }
                    Rectangle { // suffix area
                        color: "lightgray"
                        Layout.minimumWidth: 50
                        Layout.maximumWidth: 50
                        Layout.preferredWidth: 50
                        height: parent.height
                        radius: 4
                        border.color: "gray"
                        border.width: 1
                    }
                }
            }
        }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved