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
Posts: 168
Registered: ‎01-13-2011
My Device: Not Specified

Picker Bug - Please Help!

Hi Everyone! 

 

I am having a persistent problem with a Picker.  I have extracted and simplified a piece of code from my app below for testing purposes.  The problem is that using "selectedIndices" to set the Picker value to display "June" always ends up displaying July.  Every other month, year, day works perfectly.  Only June doesn't work.  What's more, even though on-screen it shows July, a trace of selectedItems[0].label returns "June"!

 

Please help!

 

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	import qnx.ui.data.DataProvider;
	import qnx.ui.picker.Picker;
	
	[SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
	
	public class SliderSample extends Sprite
	{
		private const scrollWidth:Number = 250;
		private const scrollHeight:Number = 45;
		private const monthWidthRatio:Number = 2.1;
		private const dayWidthRatio:Number = 1;
		private const yearWidthRatio:Number = 1.6;
		
		private var arrDay:Array;
		private var arrMonth:Array;
		private var arrYear:Array;
		private var arrDPs:Array;
		
		private var selectedDate:int;
		
		private var dpDay:DataProvider;
		private var dpMonth:DataProvider;
		private var dpYear:DataProvider;
		
		private var datePicker:Picker;
		
		public function SliderSample()
		{	
			this.stage.nativeWindow.visible = true;
			
			arrDay = new Array();
			arrMonth = new Array();
			arrYear = new Array();
			arrDPs = new Array();
			datePicker = new Picker();
			
			/*  Setup the years */
			for (var i:int=1; i<=2050; i++){
				arrYear.push ({label: i});
			}
			dpYear = new DataProvider(arrYear);
			
			/*  Setup the months January - December */
			arrMonth.push({label: "January"});
			arrMonth.push({label: "February"});
			arrMonth.push({label: "March"});
			arrMonth.push({label: "April"});
			arrMonth.push({label: "May"});
			arrMonth.push({label: "June"});
			arrMonth.push({label: "July"});
			arrMonth.push({label: "August"});
			arrMonth.push({label: "September"});
			arrMonth.push({label: "October"});
			arrMonth.push({label: "November"});
			arrMonth.push({label: "December"});
			dpMonth = new DataProvider(arrMonth);
			
			/*  Setup the days */
			arrDay = new Array();
			for (i = 1; i<= 31; i++){
				arrDay.push({label: i, data:i});
			}
			dpDay = new DataProvider(arrDay);
			
			/*  Gather the month, day and year data 
			*  providers and push them into an 
			*  array for the picker's dataprovider
			*/
			arrDPs.push(dpMonth);
			arrDPs.push(dpDay);
			arrDPs.push(dpYear);
			datePicker.dataProvider = new DataProvider(arrDPs);
			
			/*  Setup the size and width ratios of
			*  the picker and its columns
			*/
			datePicker.width = scrollWidth;
			datePicker.height = scrollHeight;
			datePicker.setListWidth(0, monthWidthRatio);
			datePicker.setListWidth(1, dayWidthRatio);
			datePicker.setListWidth(2, yearWidthRatio);
			
			/* Try to set the date to JUNE 19, 2011 */
			/* Note:Indices are 0-indexed */
			datePicker.selectedIndices = [(5), (18),  (2010)]
			addChild(datePicker);
			
			trace(datePicker.selectedItems[0].label); // trace resolves to "June"
		}
		

	}
}

 

Developer
Posts: 231
Registered: ‎05-03-2011
My Device: PlayBook V1 and proud of it :-)
My Carrier: Legs

Re: Picker Bug - Please Help!

cant see any logic error in your code so im favouring you have found a bug with the picker.

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
Highlighted
Developer
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: Picker Bug - Please Help!

Yaa thats true...

Me also facing same problem .

if in selected indices , if i decrease the indices by 1 then it shows may rather then june

in short anyhow it does not show me june month, for remaining months it is working perfectly.

Please provide me any solution for it.. 

Developer
Posts: 231
Registered: ‎05-03-2011
My Device: PlayBook V1 and proud of it :-)
My Carrier: Legs

Re: Picker Bug - Please Help!

please file a bug report, see thread in this forum how to do this

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
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Picker Bug - Please Help!

I've seen this and it seems to be a refresh issue.  If you query the indicies from some event, you will see that it is set to what you have, but the display is off by one.  If you create something to refresh the screen or the control, the value will update correctly.  I have not been able to get an exact pattern to this because sometimes it refreshes properly.  But since you have a nice piece of sample code going, you might be able to add some buttons and logic to see if force a refresh to the control will update the display properly.

 

Please let us know if you can reproduce it.

Developer
Posts: 168
Registered: ‎01-13-2011
My Device: Not Specified

Re: Picker Bug - Please Help!

Jtegen: I'm not sure if we can say that this is a refresh issue. You will notice that setting the date to any other than June (i.e. Any set of three indices which do not have a "5" as the first number) results in a proper display.

Also, in the above example I have added the picker to the display after setting the indices.

Do you know what function the picker class has that will force a refresh?
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Picker Bug - Please Help!

In our case, when the page containing the picker class gets swapped to another page and then back again, the correct value will display. It is driving us nuts on this one, because the indicies are correct both setting and getting, just the display will be off by one. Hopefully you will find or suggest something that will turn on a light for this.

After you set the indecies, query them and trace them out to see what you get.
Developer
Posts: 168
Registered: ‎01-13-2011
My Device: Not Specified

Re: Picker Bug - Please Help!

You will notice at the end of my code I traced and the "June" is returned as it should be. I experiment to see if U can get the value to update. More likely though I'll end up changing to a different scrolling selector class (scroller I think it might be called [on my phone right now]).
Developer
Posts: 231
Registered: ‎05-03-2011
My Device: PlayBook V1 and proud of it :-)
My Carrier: Legs

Re: Picker Bug - Please Help!

I've been doing quite a bit of testing with the code you provided and the picker displaying June is no coincedence. If you have any number of even items in the array, it will display half the array items total +1.

 

ie. remove the last 2 months and set date to 04 May - June will be displayed in the picker

 

So far an Odd number of items in the array does not have the same effect. I can't see how this can be anything but a bug with the picker, and my guess would be it's the way it's recycling and keeping track of its objects.

 

My altered code

 

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	import qnx.ui.data.DataProvider;
	import qnx.ui.picker.Picker;
	
	//[SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
	
	public class AppCodeTest extends Sprite
	{
		private const scrollWidth:Number = 250;
		private const scrollHeight:Number = 45;
		private const monthWidthRatio:Number = 2.1;
		private const dayWidthRatio:Number = 1;
		private const yearWidthRatio:Number = 1.6;
		
		private var arrDay:Array;
		private var arrMonth:Array;
		private var arrYear:Array;
		private var arrDPs:Array;
		
		private var selectedDate:int;
		
		private var dpDay:DataProvider;
		private var dpMonth:DataProvider;
		private var dpYear:DataProvider;
		
		private var datePicker:Picker;
		
		public function AppCodeTest()
		{	
			//this.stage.nativeWindow.visible = true;
			
			arrDay = new Array();
			arrMonth = new Array();
			arrYear = new Array();
			arrDPs = new Array();
			datePicker = new Picker();
			
			/*  Setup the years */
			for (var i:int=1; i<=2050; i++){
				arrYear.push ({label: i});
			}
			dpYear = new DataProvider(arrYear);
			
			/*  Setup the months January - December */
			arrMonth.push({label: "January"});
			arrMonth.push({label: "February"});
			arrMonth.push({label: "March"});
			arrMonth.push({label: "April"});
			arrMonth.push({label: "May"});
			arrMonth.push({label: "June"});
			arrMonth.push({label: "July"});
			arrMonth.push({label: "August"});
			arrMonth.push({label: "September"});
			arrMonth.push({label: "October"});
			//arrMonth.push({label: "November"});
			//arrMonth.push({label: "December"});
			dpMonth = new DataProvider(arrMonth);
			
			/*  Setup the days */
			arrDay = new Array();
			for (i = 1; i<= 31; i++){
				arrDay.push({label: i, data:i});
			}
			dpDay = new DataProvider(arrDay);
			
			/*  Gather the month, day and year data 
			*  providers and push them into an 
			*  array for the picker's dataprovider
			*/
			arrDPs.push(dpMonth);
			arrDPs.push(dpDay);
			arrDPs.push(dpYear);
			datePicker.dataProvider = new DataProvider(arrDPs);
			
			/*  Setup the size and width ratios of
			*  the picker and its columns
			*/
			datePicker.width = scrollWidth;
			datePicker.height = scrollHeight;
			datePicker.x = 100; datePicker.y=100;
			datePicker.setListWidth(0, monthWidthRatio);
			datePicker.setListWidth(1, dayWidthRatio);
			datePicker.setListWidth(2, yearWidthRatio);			
			/* Try to set the date to JUNE 19, 2011 */
			/* Note:Indices are 0-indexed */
			datePicker.selectedIndices = [(4), (18),  (2010)]
			addChild(datePicker);			
			
			datePicker.addEventListener(Event.SELECT, datePicked);
			datePicker.addEventListener(Event.OPEN, pickerOPenend);
			trace(datePicker.selectedItems[0].label+":"+datePicker.selectedItems[1].label+":"+datePicker.selectedItems[2].label);		
		}
		
		protected function pickerOPenend(event:Event):void
		{
			// TODO Auto-generated method stub
			trace(datePicker.selectedItems[0].label+":"+datePicker.selectedItems[1].label+":"+datePicker.selectedItems[2].label);
		}
		
		protected function datePicked(event:Event):void
		{
			// TODO Auto-generated method stub
			trace(datePicker.selectedItems[0].label+":"+datePicker.selectedItems[1].label+":"+datePicker.selectedItems[2].label);
		}		
	}
}

 

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
Developer
Posts: 168
Registered: ‎01-13-2011
My Device: Not Specified

Re: Picker Bug - Please Help!

Excellent work figuring that out. Am I the only one getting fed up with the Tablet OS API display elements?