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: 109
Registered: ‎12-04-2008
My Device: Playbook, Torch 9800, Storm 9530, Tour 9630
My Carrier: Telus
Accepted Solution

Odd Dropdown list behavior: can only select top 3

I have a dropdown list populated from the SharedObject and it works just fine (can add and delete or delete all using the GUI I created) but when it's expanded, I can only select one of the top 3 items.

Let's say when I expand the list, I see these entries:

test1

5_up_top

diamonds

spider

bigX

 

I can select test1, 5_up_top and diamonds but i cannot select spider or bigX.

 

Huh?!

 

var dp:DropDown = new DropDown();
dp.rowHeight = CONTROL_HEIGHT;
dp.width = 2* LABEL_WIDTH + LABEL_SPACER;
dp.height = CONTROL_HEIGHT+ HALF_LABEL_SPACER;
dp.x = OFFSET + LABEL_SPACER + OFFSET;
dp.y = 4 * CONTROL_HEIGHT + LABEL_SPACER;
dp.rowCount=8;
dp.dataProvider = getSharedData();

 and getSharedData():

private function getSharedData():DataProvider{
	_lso = SharedObject.getLocal("LoadGames");
	var valuePair:Object = _lso.data["puzzles"];
		
	var dp:DataProvider = new DataProvider();
	for each(var obj:Object in valuePair){
		if(obj != null){
			dp.addItem({label:obj["title"], data:obj["game"]});
		}
	}
	return dp;
}

9.4 simulator running AIR2.5 on Vista32.

I've poked around on this forum but haven't seen anything like this. Any ideas?

TIA,

Brian

 

PlayBook Apps: Sudoku Pro
Smartphone Apps: Compass | MultiClock
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Odd Dropdown list behavior: can only select top 3

Are all the items (data and label) unique?

Developer
Posts: 109
Registered: ‎12-04-2008
My Device: Playbook, Torch 9800, Storm 9530, Tour 9630
My Carrier: Telus

Re: Odd Dropdown list behavior: can only select top 3

Hi John,

Thanks for your response. Yes, they are.

Further to the above, if I delete one of the top 3, I can then select 'spider' (because it's now the third item) but I still cannot select 'bigX'

 

cheers...B

PlayBook Apps: Sudoku Pro
Smartphone Apps: Compass | MultiClock
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Odd Dropdown list behavior: can only select top 3

that's strange never seen that behaviour before -- can you confirm by creating another dropdown elsewhere with no special variables or methods just straight up manual data and configurations.

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

Re: Odd Dropdown list behavior: can only select top 3

For fun, try not using the shared object function.  Do something like:

 

mylist.dataProvider = new DataProvider( [ {label:'A',data:'1'},{label:'B',data:'2'}, etc ] );

 

to see if the list is the issue or the function from the shared object.

Developer
Posts: 109
Registered: ‎12-04-2008
My Device: Playbook, Torch 9800, Storm 9530, Tour 9630
My Carrier: Telus

Re: Odd Dropdown list behavior: can only select top 3

[ Edited ]

Thank you both.

Confirmed: using John's straight data as the provider corrects the symptom (though not the problem).

I'll try creating an array from the SO and passing that instead. Will report back soon.

I wonder what the problem is...

Thanks again,

B

 

[Edit: Jumped the gun, I think. This dropdown is in a popup 'panel' and I have another dropdown in another panel that also uses the same SO. It's the other one that I changed and it worked fine. As a quick further test, I changed the dropdown (that was originally giving me problems) to use the static list expecting it to now be fine as well but it is not. I still cannot select 'D' or 'E' from this list:

dp.rowCount=8;
dp.dataProvider = new DataProvider( [ {label:'A',data:'1'},{label:'B',data:'2'},{label:'C',data:'3'},{label:'D',data:'4'},{label:'E',data:'5'} ] );
		
//dp.dataProvider = getSharedData();

 I'll do some more testing on the differences between the panels and will let you know what I find...unless something occurs to you for me to check. Smiley Happy

 

Thanks again, 

B

 

PlayBook Apps: Sudoku Pro
Smartphone Apps: Compass | MultiClock
Developer
Posts: 109
Registered: ‎12-04-2008
My Device: Playbook, Torch 9800, Storm 9530, Tour 9630
My Carrier: Telus

Re: Odd Dropdown list behavior: can only select top 3

Okay: my bad.

On the panel, I had strategically placed a blank, non-selectable TextField to be used for messages. (Do you see where this is going? Smiley Tongue). I added this child AFTER the dropdown. Adding it BEFORE the dropdown placed it underneath and cured the aberrant behaviour. Like this:

var dp:DropDown = new DropDown();
...
dp.rowCount=8;
dp.dataProvider = getSharedData();

messageText.selectable = false;
messageText.text = ""; //Note to self: don't ever do this.
messageText.x = OFFSET + LABEL_SPACER;
messageText.y = 8 * CONTROL_HEIGHT + LABEL_SPACER;
messageText.defaultTextFormat = buttonFormat;
messageText.width = w;
messageText.height = 2* CONTROL_HEIGHT;
addChild(messageText); //<<< This works because the blank unselectable TextField is placed before the dp

addChild(dp);
//addChild(messageText);	//<<< This fails because the blank TextField is placed over top of the dp	

Thank you again for your helpful responses. They helped me see what was there...even when it was invisible.

 

cheers...B

 

PlayBook Apps: Sudoku Pro
Smartphone Apps: Compass | MultiClock
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Odd Dropdown list behavior: can only select top 3

The fix for that is to subscribe to the dropwdown when it gains focus and move it to the top of the parent's children.

Developer
Posts: 109
Registered: ‎12-04-2008
My Device: Playbook, Torch 9800, Storm 9530, Tour 9630
My Carrier: Telus

Re: Odd Dropdown list behavior: can only select top 3

Excellent tip; thanks. Do you have a snippet handy that shows this?

 

Brian

PlayBook Apps: Sudoku Pro
Smartphone Apps: Compass | MultiClock
Highlighted
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Odd Dropdown list behavior: can only select top 3

Certainly do.  It is also available in the community AS3 library.

package com.lib.playbook.controls
{
	/*
	MIT License:
	
	Copyright (C) 2011 by John Tegen/O2 Interactive
	
	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:
	
	The above copyright notice and this permission notice shall be included in
	all copies or substantial portions of the Software.
	
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	THE SOFTWARE.
	*/
	import flash.events.Event;
	import flash.events.FocusEvent;
	
	import qnx.ui.listClasses.DropDown;
	
	public class DropDown extends qnx.ui.listClasses.DropDown
	{
		public var dataField : String = 'data';
		public var defaultSelection : * = '';
		
		/////////////////////////////////////////////////////////////////////////
	public function DropDown()
	{
		super();
		this.addEventListener(FocusEvent.FOCUS_IN, HasFocus );
	}
		
		///////////////////////////////////////////////////////////////////////////
	private function HasFocus( event : Event ) : void
	{
		this.parent.setChildIndex( this, this.parent.numChildren-1 );
	}
		
		////////////////////////////////////////////////////////////////////
	public function set selection( value : * ) : void
	{
			var entry   : Object;
			var counter : int = 0;
			for each( entry in this.dataProvider.data )
			{
				if( entry[ this.dataField ] == value )
				{
					this.selectedIndex = counter;
					break;
				}
				counter++;
			}
	}
		
		//////////////////////////////////////////////////////////////////////
	public function get selection() : *
	{
		return this.selectedItem ? this.selectedItem[ this.dataField ] : this.defaultSelection;
	}
    }
}