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
Posts: 4
Registered: ‎08-09-2013
My Device: Z10
My Carrier: 672043543
Accepted Solution

ListDialog open twice bug

Hi!

 

I think i found a bug in the ListDialog component. The second time you open a ListDialog you cannt select any item in there and there are strange things in the scrolling. Just use the code below to test it.

 

public class BBListBug extends Sprite

{

public function BBListBug()

{

stage.addEventListener(MouseEvent.CLICK, onClick_stage);

}

 

private function onClick_stage(event : MouseEvent) : void

{

 

var options : Array = new Array();

for (var i : int = 0; i < 40; i++) 

{

options.push(i);

}

 

var myList : ListDialog = new ListDialog();

myList.title = "TEST";

myList.addButton("Cancel");

myList.addButton("OK");

myList.items = options;

myList.show();

}

}

 

Any idea how can this be solved?

Highlighted
Retired
Posts: 427
Registered: ‎02-22-2012
My Device: BlackBerry Z10, BlackBerry Dev Alpha C, BlackBerry PlayBook
My Carrier: Bell

Re: ListDialog open twice bug

Try this:

 

package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import qnx.fuse.ui.buttons.LabelButton;
	import qnx.fuse.ui.events.ListEvent;
	import qnx.fuse.ui.events.ScrollEvent;
	import qnx.fuse.ui.listClasses.List;
	import qnx.fuse.ui.listClasses.ListSelectionMode;
	import qnx.fuse.ui.listClasses.ScrollDirection;
	import qnx.ui.data.DataProvider;
	
	[SWF(height="1280", width="768", frameRate="60", backgroundColor="#FFFFFF")]
	public class ListTest extends Sprite
	{
		private var myList:List = new List(); 
		private var mySelection:String;
		
		public function ListTest()
		{
			initializeUI();
		}
		
		private function initializeUI():void
		{
			var categoryBtn:LabelButton = new LabelButton();
			categoryBtn.label = "Category";
			categoryBtn.addEventListener(MouseEvent.CLICK, onCategoryBtnClick);
			addChild(categoryBtn);
		}
		
		private function onCategoryBtnClick(event:MouseEvent):void{
			createMyList();
		}
		
		private function createMyList():void {
			var options : Array = new Array();
			for (var i : int = 0; i < 40; i++) 
			{
				options.push({label: i});
			}
			
			myList.width = stage.stageWidth;            
			myList.height = stage.stageHeight;
			myList.columnWidth = 100;
			
			//set the dataProvider
			myList.selectionMode = ListSelectionMode.SINGLE;
			myList.scrollDirection = ScrollDirection.VERTICAL;
			myList.dataProvider = new DataProvider(options);
			
			myList.addEventListener(ListEvent.ITEM_CLICKED, onListClick);
			myList.addEventListener(ScrollEvent.SCROLL_END, onScroll);
			myList.addEventListener(ScrollEvent.SCROLL_BEGIN, onScrollStart);
			
			var myButton:LabelButton = new LabelButton();
			myButton.label = "Submit";
			myButton.width = 300;
			myButton.addEventListener(MouseEvent.CLICK, onSubmitClick);
			myList.footerView = myButton;

			this.addChild(myList);
		}
		
		private function showList():void{
			this.addChild(myList);
		}
		
		private function hideList():void{
			this.removeChild(myList);
			trace("Selection was: "+mySelection);
		}
		
		private function onSubmitClick(event:MouseEvent):void{
			hideList();
		}
		
		private function onListClick(event:ListEvent):void {
			trace("Item clicked: " + event.data.label);
			trace("Index clicked: " + event.index);
			mySelection = event.data.label;
		}
		
		private function onScroll(event:ScrollEvent):void {
			trace("Finished scrolling...");            
		}
		
		private function onScrollStart(event:ScrollEvent):void {
			trace("Start scrolling...");            
		}        
	}
}

 

Follow me on Twitter: @dustinmalik
-----------------------------------------------------------------------------------------------------
Keep up to date on BlackBerry development: http://devblog.blackberry.com/
New Contributor
Posts: 4
Registered: ‎08-09-2013
My Device: Z10
My Carrier: 672043543

Re: ListDialog open twice bug

Sorry for the delay but i was on vacacions. Tried this, it works, definitely i can do a workaround with this. But this is a List. The bug with the ListDialog is known? Any chances to fix it in near future?

BlackBerry Development Advisor
Posts: 172
Registered: ‎10-25-2010
My Device: Not Specified

Re: ListDialog open twice bug

What version of the SDK are you using? Can you try the lastest 3.2.1 SDK. We've tried to reproduce using your code sample and we don't see the issue. It would also be good to know which OS version you are using.

New Contributor
Posts: 4
Registered: ‎08-09-2013
My Device: Z10
My Carrier: 672043543

Re: ListDialog open twice bug

Updated to the lastest sdk 3.2.1. Created a new project in FDT and made sure that im using the 3.2.1 SDK. Put my code above and compiled. It crashed after start. I configured the compiler argument -forceAirVersion 3.1 and tried again. Now the app started correctly but the bug persists. The second time i opened a ListDialog i cant choose an option and the scroll is flawed. Uploaded a video here:

https://dl.dropboxusercontent.com/u/2515162/IMG_1823.MOV

 

Using FDT 7 on Mac 10.8.4

BlackBerry Development Advisor
Posts: 172
Registered: ‎10-25-2010
My Device: Not Specified

Re: ListDialog open twice bug

The issue is that a dialog is the first component created, which causes some invalidation issues to occur.

 

If you put the following in your constructor, the framework will get initialized correctly and the dialog should work everytime.

 

var ui:UIComponent = new UIComponent();

 

New Contributor
Posts: 4
Registered: ‎08-09-2013
My Device: Z10
My Carrier: 672043543

Re: ListDialog open twice bug

needed to do addChild(ui) too, but it worked!! Still a annoying bug if you don't know the magic spell. Smiley Wink

 

Thanks!!!