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
Developer
ChernyshovYuriy
Posts: 116
Registered: ‎11-18-2010
My Device: BlackBerry PlayBook
My Carrier: null

ScrollPane ScrollEvent problem

Hello dear developers.

What i discover today is that scroll pane doesnt dispatch any scroll events in case of vertical scroll if width of the components inside scroll container higher that width of the scroll pane itself. It takes a time for me to find a source of the problem with scroll events...I think this is a bug of the component.

Here is a code:

 

package
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	
	import qnx.ui.events.ScrollEvent;
	import qnx.ui.listClasses.ScrollDirection;
	import qnx.ui.listClasses.ScrollPane;
	
	public class PlayBookTest extends Sprite
	{
		public function PlayBookTest()
		{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			
			var scrollPane:ScrollPane = new ScrollPane();
			var scrollContent:Sprite = new Sprite();
			
			scrollPane.addEventListener(ScrollEvent.SCROLL_MOVE, this.scrollPane_ScrollMoveHandler);
			scrollPane.addEventListener(ScrollEvent.SCROLL_BEGIN, this.scrollPane_ScrollBeginHandler);
			scrollPane.addEventListener(ScrollEvent.SCROLL_END, this.scrollPane_ScrollEndHandler);
			
			scrollPane.setPosition(20, 20);
			scrollPane.setSize(300, 500);
			scrollPane.setScrollContent(scrollContent);
			scrollPane.scrollDirection = ScrollDirection.BOTH;
			this.addChild(scrollPane);
			
			var shape:Shape;
			for (var i:int; i < 50; ++i)
			{
				shape = new Shape();
				shape.graphics.beginFill(0xFFFFFF * Math.random());
				shape.graphics.drawRect(0, 0, 350, 50);
				shape.graphics.endFill();
				
				shape.y = 50 * i;
				
				scrollContent.addChild(shape);
			}
			scrollPane.update();
		}
		
		private function scrollPane_ScrollMoveHandler(event:ScrollEvent):void
		{
			trace("CL Scroll Move : " + event)
		}
		
		private function scrollPane_ScrollBeginHandler(event:ScrollEvent):void
		{
			trace("CL Scroll Begin : " + event)
		}
		
		private function scrollPane_ScrollEndHandler(event:ScrollEvent):void
		{
			trace("CL Scroll End : " + event)
		}
	}
}

 

 

At this line:

shape.graphics.drawRect(0, 0, 350, 50);

try to set width of the shape smaller or equally than width of the scroll pane and You will get all events.

 

Yuriy.

 

 

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: ScrollPane ScrollEvent problem

hey,

 

yeah i can confirm the bug. ran into the problem a couple of weeks ago. really [bleeped] me off to no end. only the ScrollDirection.VERTICAL scrollpanes give off expected events. anytime you include any horizontal scrolling, events are not fired off.

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
New Contributor
aferrandini
Posts: 2
Registered: ‎06-18-2011
My Device: BlackBerry 9780, PlayBook
My Carrier: Vodafone

Re: ScrollPane ScrollEvent problem

You can solve this problem extending the ScrollPane class with your own like this

 

package
{
	import qnx.ui.events.ScrollEvent;
	import qnx.ui.listClasses.ScrollPane;
	
	public class MyScrollPane extends ScrollPane
	{
		public function MyScrollPane()
		{
			super();
		}
		
		override protected function scrollUpdate(e:ScrollEvent):void
		{
			// TODO Auto Generated method stub
			this.adjustScrollbars();

			e.stopImmediatePropagation();

			if (hasEventListener(ScrollEvent.SCROLL_MOVE))
			{
				var event:ScrollEvent = e.clone() as ScrollEvent;
				dispatchEvent(event);
			}
			
			this.showShadows();
			return;
		}
	}
}

 

 

Hope it helps you!

Please use plain text.