~ubuntu-sdk-team/ubuntu-ui-toolkit/textHandlerCleanUpRTM

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/TextCursor.qml

  • Committer: Christian Dywan
  • Date: 2015-02-23 10:25:35 UTC
  • Revision ID: christian.dywan@canonical.com-20150223102535-604p9n3yf7fl1b9y
Change scrolling hack to properties absX and absY

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    objectName: "textCursor"
47
47
    //Caret instance from the style.
48
48
    property Item caret: __styleInstance.caret
49
 
 
50
 
    // Returns "x" or "y" relative to the item handlers are a child of
51
 
    function mappedCursorPosition(coordinate) {
52
 
        // FIXME: Hack to catch scrolling
 
49
    property int absX: {
 
50
        return fakeCursor.parent.mapFromItem(handler.main, cursorItem.x, cursorItem.y).x
 
51
    }
 
52
    property int absY: {
 
53
        // Take parent flickable movement into account
53
54
        var flickable = handler.main;
54
55
        do {
55
56
            flickable = flickable.parent;
56
57
        } while (!flickable.contentY && flickable != fakeCursor.parent);
57
 
        flickable.contentY;
 
58
        return fakeCursor.parent.mapFromItem(handler.main, cursorItem.x, cursorItem.y).y
 
59
    }
58
60
 
59
 
        var cpos = fakeCursor.parent.mapFromItem(handler.main, cursorItem.x, cursorItem.y)[coordinate];
 
61
    // Returns "x" or "y" relative to the item handlers are a child of
 
62
    function mappedCursorPosition(coordinate) {
 
63
        var cpos = cursorItem["abs" + coordinate.toUpperCase()];
60
64
        cpos += handler.frameDistance[coordinate];
61
65
        cpos += handler.input[coordinate];
62
66
        cpos -= handler.flickable["content" + coordinate.toUpperCase()];