March 9, 2011

Peter Hewat Peter Hewat
Lab Rat
4 posts

PathView keypressed handling could be better

 

Hello all,

PathView works great when you flick it but not so great when you use key presses. If you keep a key pressed for a while, you get key repeats that make the current index change very quickly (this is normal behavior). The thing is that if there aren’t many items in the PathView (ex: 10), the animation doesn’t have time to start moving towards one item that it has to move towards another in the other direction. What ends up happening is that the list skips around instead of turning around in one direction as you’d expect it.

A way to fix this would be that instead of making the graphics go to the current index that remains in the bounds of the list, it should go to an index on which you don’t apply a modulo. For example, it the bounds are [0..9], when you get to index 9, incrementing would get the “graphical index” to 10 and not 0. That way, the graphics keep on spinning until it reaches 10 which visually is the next 0.

In the mean time, I have set highlightMoveDuration to 100 (default is 300ms). That way the spin is so fast that this problem doesn’t occur. That said, a proper fix would be welcome.

Cheers :)

3 replies

March 9, 2011

Peter Hewat Peter Hewat
Lab Rat
4 posts

Here is an example:

  1. import QtQuick 1.0
  2.  
  3.  Rectangle {
  4.      width: 150; height: 150
  5.      property real itemSize: 20
  6.  
  7.      PathView {
  8.          id: spinner
  9.          anchors.fill: parent
  10.          model: 10
  11.          delegate: Text { text: index; font.pointSize: itemSize - 4}
  12.          focus: true
  13.          //highlightMoveDuration: 100
  14.          path: Path {
  15.              startX: width - itemSize; startY: -itemSize/2
  16.              PathLine { x: width - itemSize; y: spinner.count * itemSize}
  17.          }
  18.          Keys.onDownPressed: decrementCurrentIndex()
  19.          Keys.onUpPressed: incrementCurrentIndex()
  20.      }
  21.      Text {
  22.           text: "Press Up/Down to spin\nCurrent item index: " + spinner.currentIndex
  23.      }
  24.  }

Keep the Up or Down key pressed and you will see the numbers not spinning around as you’d expect.
Remove the commented line to have it spin properly (but too fast…).

March 10, 2011

mbrasser mbrasser
Hobby Entomologist
401 posts

Hi,

Thanks for the information and example — would you be able to add it as an official bug report using http://bugreports.qt.nokia.com (that way it is much more likely to be addressed, progress can be tracked, etc)?

Thanks,
Michael

March 10, 2011

Peter Hewat Peter Hewat
Lab Rat
4 posts

Hi Michael,

I have created a new entry in the official bug report as you suggested:
http://bugreports.qt.nokia.com/browse/QTBUG-18045

Cheers :)

 
  ‹‹ Importing an existing QScriptExtensionPlugin to QML      Porting QML to JS/HTML5 ››

You must log in to post a reply. Not a member yet? Register here!