[Solved?] Getting text including "preedit" from qt-components TextArea [MeeGo / N950]



  • Anyone knows a quick way to get the text including the preedit text when using the virtual keyboard on the n950?

    Following code
    @
    TextArea {
    onTextChanged: {
    console.log("Text:", text);
    }
    }
    @

    Returns this:
    @
    Text:
    Text:
    Text:
    Text:
    Text: Test
    @

    When entering "Test" with the virtual keyboard on the N950. I need to know how it can be done with the beta2 firmware, if this is already patched in an internal release, this does not help me now. I myself haven't found a way with the current sources.



  • Ok, I tried a bit and found a working solution. Maybe someone else has a better one and will find this to correct me :)

    Actual output when having "Hello world" in the TextArea and click after the first "o" and insert "123" with the virtual keyboard:
    @
    Text: Hello world
    Realtext: Hello world
    Text: Hello world
    Realtext: Hello world
    Text: Hello world
    Realtext: Hello 1 world
    Text: Hello world
    Realtext: Hello 12 world
    Text: Hello world
    Realtext: Hello 123 world
    @

    Code:
    @
    TextArea {
    id: textArea

    property string realText
    
    onTextChanged: {
        var tmp = text;
    
        if ( cursorPosition != -1 ) {
            tmp = tmp.substr(0, cursorPosition) + platformPreedit + tmp.substr(cursorPosition);
        }
    
        textArea.realText = tmp;
    
        console.log("Text:", text);
        console.log("Realtext:", realText);
    }
    

    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.