Forums

OverviewFelgo 2 Support (Qt 5) › AppTextField inputMethodHints does not work on desktop

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18998

    Javier

    This example shows some AppTextFields with inputMethodHints. It works fine on iOS, it restricts keys and shows the appropriate keyboards. However, it does not work on desktop (at least on Linux). Is this supposed to work only on mobile devices? Below, there is a link to the web editor and the code.

    https://felgo.com/web-editor/?snippet=503d97d1

    import QtQuick 2.10
    import Felgo 3.0
    import QtQuick.Controls 1.3
    
    App{
        NavigationStack{
            Page{
                title: "Input method hints"
    
                Column {
                    anchors.fill: parent
                    spacing: dp(20)
    
                    Item{
                        width: 1
                        height: dp(10)
                    }
    
                    AppTextField{
                        anchors.horizontalCenter: parent.horizontalCenter
                        borderColor: "black"
                        borderWidth: 2
                        width: parent.width - dp(20)
                        inputMethodHints: Qt.ImhDigitsOnly
                        placeholderText: qsTr("Only digits")
                    }
    
                    AppTextField{
                        anchors.horizontalCenter: parent.horizontalCenter
                        borderColor: "black"
                        borderWidth: 2
                        width: parent.width - dp(20)
                        validator: RegExpValidator { regExp: /^[0-9\+\-\#\*\ ]{6,}$/ }
                        inputMethodHints: Qt.ImhDialableCharactersOnly
                        placeholderText: qsTr("Only dialable characters")
                    }
    
                    AppTextField{
                        anchors.horizontalCenter: parent.horizontalCenter
                        borderColor: "black"
                        borderWidth: 2
                        width: parent.width - dp(20)
                        inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
                        placeholderText: qsTr("Only email characters")
                    }
    
                    AppTextField{
                        anchors.horizontalCenter: parent.horizontalCenter
                        borderColor: "black"
                        borderWidth: 2
                        width: parent.width - dp(20)
                        inputMethodHints: Qt.ImhUrlCharactersOnly
                        placeholderText: qsTr("Only URL characters")
                    }
                }
            }
        }
    }
    

     

    #19034

    Günther
    Felgo Team

    Hi,

    the inputMethodHints feature of AppTextField is based on the TextField QML Type by Qt. The settings may have different effect on different platforms. Also, as a Desktop keyboard usually covers all available keys, the input hints are more focused on e.g. mobile devices, where the amount of shown keys is more limited and the usage of a subset of keys or different keyboard makes sense.

    Best,
    Günther

     

    #19049

    Javier

    Hi Günther,

    I thought inputMethodHints applied some kind of validation over the input text, but it does not seem to be the case, so I think I have to define some kind of validation or regular expression in the validator property.

    #19057

    Günther
    Felgo Team

    Correct, input validation is not covered by the input method hints.
    They only suggest which kind of user input you expect, to e.g. show a different keyboard on mobiles.

     

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support