Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
New Contributor
apple666
Posts: 5
Registered: ‎06-20-2011
My Device: playbook
My Carrier: aaa
Accepted Solution

What event will be triggered when using finger to scroll the screen?

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?

Please use plain text.
Developer
CoCopia
Posts: 231
Registered: ‎05-03-2011
My Device: PlayBook V1 and proud of it :-)
My Carrier: Legs

Re: What event will be triggered when using finger to scroll the screen?

Not sure what you mean by finger to scroll, can you explain a bit more? 

Keep the Forum productive and useful for all. Click Kudos button if I've helped you. Select Solved to help everyone.

PlayBook qualifying app - Pandoras' Lights
Blog - CoCopia.co.uk Catch me on Twitter cocopia_apps
Please use plain text.
Regular Contributor
yaddesign
Posts: 53
Registered: ‎04-28-2011
My Device: Playbook
My Carrier: Not Specified

Re: What event will be triggered when using finger to scroll the screen?

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

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: What event will be triggered when using finger to scroll the screen?

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.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
New Contributor
apple666
Posts: 5
Registered: ‎06-20-2011
My Device: playbook
My Carrier: aaa

Re: What event will be triggered when using finger to scroll the screen?

Thanks for your guys help a lot!

Please use plain text.