Results 1 to 4 of 4

Thread: Cursor Position and Flickable Issue in TextEdit

  1. #1
    Join Date
    Jul 2013
    Posts
    33
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Cursor Position and Flickable Issue in TextEdit

    Hi Guyz

    I cannot place cursor in middle of the text inside TextEdit. i.e., i need to place cursor where ever i click on text. As i implemented MouseArea on TextEdit it does not allow me and i cannot successfully flick the content also as keyboard takes the precedence the moment i click on TextEdit field.

    And how do i pass co-ordinates for flick(x,y) as i see it has to be between 0-1 ? As i click on Image on top or below flick needs to scroll up and down
    Attached my code for ref:
    Qt Code:
    1. Rectangle{
    2. id: contactBox1
    3. anchors{left: parent.left;leftMargin: 200;top: parent.top;topMargin: 200;bottom: parent.bottom;bottomMargin: 120}
    4. width: 270
    5. clip: true
    6. color: "red"
    7.  
    8. Image {
    9. id:topArrow
    10. anchors{left: parent.left;leftMargin: parent.width/2-topArrow.width/2}
    11. anchors{top: parent.top }
    12. source: "WheelPickerArrow_Down.png"
    13. visible: northAmericaFlick.contentHeight > northAmericaFlick.height
    14. MouseArea{
    15. anchors.fill: parent
    16. onClicked: {
    17. northAmericaFlick.flick(1,0.2)
    18. }
    19. }
    20. }
    21.  
    22. Text{
    23. id: northAmericaRegion
    24. anchors{left: parent.left;leftMargin: 20;top: parent.top;topMargin: 20}
    25. text: qsTr("North America:")
    26. font.pixelSize: 26
    27. }
    28.  
    29. Flickable{
    30. id: northAmericaFlick
    31. x: 20
    32. anchors{top: parent.top;topMargin: 50 }
    33. height: Qt.inputMethod.visible ? parent.height-230 : parent.height-100
    34. width: parent.width
    35. contentWidth: 230
    36. contentHeight: northRegion.contentHeight
    37. flickableDirection: Flickable.VerticalFlick
    38. clip: true
    39.  
    40. function ensureNAVisible(r){
    41. console.log("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW "+r.x )
    42. console.log("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW "+r.y)
    43. console.log("contentX "+ contentX )
    44. console.log("contentY "+ contentY)
    45. console.log("height "+ r.height)
    46.  
    47.  
    48. if (contentX >= r.x)
    49. contentX = r.x;
    50. else if (contentX+width <= r.x+r.width)
    51. contentX = r.x+r.width-width;
    52. // if (contentY >= r.y)
    53. // contentY = r.y;
    54. // else if (contentY+height <= r.y+r.height)
    55. // contentY = r.y+r.height-height;
    56.  
    57. contentY = r.y
    58.  
    59. }
    60.  
    61. TextEdit{
    62. id: northRegion
    63. text: "866-984-3766"
    64. font.pixelSize:24
    65. anchors.fill: parent
    66. width: parent.width-30
    67. color: "#8F8F8F"
    68. clip: true
    69. persistentSelection: true
    70. wrapMode: Text.WrapAnywhere
    71.  
    72. onCursorRectangleChanged:
    73. {
    74. northAmericaFlick.ensureNAVisible(cursorRectangle)
    75. }
    76. }
    77. }
    78.  
    79. Image {
    80. id:bottomArrow1
    81. anchors{left: parent.left;leftMargin: parent.width/2-bottomArrow1.width/2}
    82. anchors{bottom: parent.bottom;bottomMargin: 5}
    83. source:"WheelPickerArrow_Up.png"
    84. visible: northAmericaFlick.contentHeight > northAmericaFlick.height
    85. MouseArea{
    86. anchors.fill: parent
    87. onClicked: {
    88. [COLOR="#FF0000"] northAmericaFlick.flick(10,10)[/COLOR] // how do i pass co-ordinates for flick ?
    89. }
    90. }
    91. }
    92.  
    93. MouseArea{
    94. anchors.fill: parent
    95. propagateComposedEvents: true
    96. onClicked: {
    97. console.log("DDDDDDDDDDDDDDddd")
    98. northRegion.forceActiveFocus()
    99. northRegion.cursorVisible=true
    100. Qt.inputMethod.show()
    101. mouse.accepted=false
    102. }
    103. }
    104.  
    105. }
    106.  
    107.  
    108. InputPanel {
    109. id: inputPanel
    110. z: 1
    111. y: Qt.inputMethod.visible ? parent.height - inputPanel.height : parent.height
    112. anchors.left: parent.left
    113. anchors.right: parent.right
    114. }
    To copy to clipboard, switch view to plain text mode 
    Can Anyone help me on this

    Regards
    Bala B
    Last edited by anda_skoa; 11th March 2017 at 11:08. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Cursor Position and Flickable Issue in TextEdit

    Flickable.flick() is for starting a scrolling movement by specifiying velocities.

    If you need to position a Flickable you'll need to change contentX and contentY.

    Cheers,
    _

  3. #3
    Join Date
    Jul 2013
    Posts
    33
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Cursor Position and Flickable Issue in TextEdit

    Thank you..But how do i move flick line by line of textedit content. Should i consider current position and use line height of content ?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Cursor Position and Flickable Issue in TextEdit

    Yes, that would be a thing I would try.

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 16th September 2012, 10:28
  2. Getting Cursor position within QMdiSubWindow
    By stevel in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2012, 11:09
  3. Cursor Position in scene
    By rogerholmes in forum Newbie
    Replies: 2
    Last Post: 12th March 2010, 15:31
  4. Make the cursor visible in textEdit (Qt3.3.5)
    By vermarajeev in forum Qt Programming
    Replies: 9
    Last Post: 24th January 2007, 22:50
  5. Cursor scene position
    By xgoan in forum Qt Programming
    Replies: 1
    Last Post: 26th December 2006, 13:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.