07-01-2011 01:43 AM
I want to make the chart scrollable, now i can do it by using mouse to drag, but how can i implement it by using finger to scroll?
The question is I don't know when using finger to scroll the screen, what event will triggered?
please help me if there is any solution?
Solved! Go to Solution.
07-01-2011 04:52 AM
Not sure what you mean by finger to scroll, can you explain a bit more?
07-01-2011 04:52 AM
You can use the same code as the mouse. Mouse events are also fired when you use a finger on a touchscreen. However, if you want more functionality, for example pinch-to-zoom etc, you'll have to look at the TouchEvent class.
Playbook App: Car Crash
07-01-2011 09:48 AM
As yaddesign says, just listen for MOUSE_DOWN and MOUSE_UP as you would for the mouse, since the mouse events are always fired for the first touch to the screen. (A second, simultaneous touch will not trigger any mouse events, since only one mouse at a time is supported.)
Note also that for this sort of purpose (scrolling a list) you do NOT want to listen for MOUSE_MOVE events in between. Those are sent far too often (100 Hz), so there's a big hit on performance, and you can't update the display more often than the changes are rendered anyway. What you do instead is use an ENTER_FRAME handler, as those fire (by definition) only as often as the display changes are rendered.
Here's the basic sequence:
1. install the MOUSE_DOWN listener for your chart
2. when MOUSE_DOWN is received, install a MOUSE_UP listener and an ENTER_FRAME listener, and remember the starting position (and, possibly, time)
3. in ENTER_FRAME, monitor the change in mouse position and scroll your list appropriately, possibly recording information about time as well so you can calculate speed of movement
4. when MOUSE_UP fires, remove MOUSE_UP and ENTER_FRAME handlers and stop scrolling, or calculate some velocity info and initiate a "tween" to continue sliding the list for a while afterwards
Note that if that's all you want to happen, you should probably just use qnx.ui.listClasses.ScrollPane as it's already doing all the hard work for you, is optimized properly (i.e. not naively using MOUSE_MOVE), and has various extra features you may want such as the scroll position indicator.
07-02-2011 06:00 PM
Thanks for your guys help a lot!