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
Regular Contributor
Posts: 62
Registered: ‎12-21-2010
My Device: Not Specified

ColorPicker for Tablet OS

Hey guys

 

Am i right in saying that the Colorpicker is not avalible for use when using the BB playbook SDK?

 

If so what is a good way round this if i want a colorpicker?

 

Thanks

Chris

Highlighted
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: ColorPicker for Tablet OS

You are correct.

 

Implementation will depend on the diversity of colors you want to choose from.  You can do something easy and have a list of colors (horizontal, vertical or tile) of 32 or so discrete colors to choose, or you can have a rainbow of 64K of colors in a bitmap that you select from.  The drawback of the bitmap approach is that you have a finger to pick a pixel which would not be very accurate.  You could mimic the Flax color chooser but at a larger scale.

 

Something on my todo list.  Just have not gotten to it yet.

Regular Contributor
Posts: 62
Registered: ‎12-21-2010
My Device: Not Specified

Re: ColorPicker for Tablet OS

Yeah i'm more likely to use the list method, so how would you go about doing that?

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: ColorPicker for Tablet OS

Here's the approach.  If you get stuck, I can send sample code later today.

 

Create a custom alternating list renderer.

Add a Sprite as a member and allocate it.

Add it as a child in onAdded virtual method (override) and remove it on onRemoved();

Hide the default label.

In drawLabel() override method, check for data and draw the color you want in the sprite attribute (clear,lineStyle,beginFill,drawRectangle,endFill).

Size the sprite to the height and width of the cell.

 

Sorry for the lack of code.  Not near my code set to post right now.  There are other threads that cover custom renderers. Not certain if there is one that covers setting a unique color for each item.

 

Regular Contributor
Posts: 62
Registered: ‎12-21-2010
My Device: Not Specified

Re: ColorPicker for Tablet OS

Ok i'll give that a shot

 

Thanks for all you help

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: ColorPicker for Tablet OS

Here is a renderer that places the label over a colored background.  You can just make the label.visible = false in the constructor to just have a colored background.

 

package renderer
{
	import flash.display.Sprite;
	import flash.text.TextFormat;
	import qnx.ui.listClasses.DropDownCellRenderer;
	
  public class ColorListRenderer extends DropDownCellRenderer
  {
	private var cell :Sprite;
		
		////////////////////////////////////////////////////////////////
	public function ColorListRenderer()
	{
		super();
		this.cell = new Sprite();
		this.label.visible = true;		
		this.label.format = new TextFormat( null, null, 0x000000 );
	}
		
		///////////////////////////////////////////////////////////////
	override protected function onAdded():void
	{
		super.onAdded();
			
		this.addChild( this.cell );
		this.setChildIndex( this.label, this.numChildren-1 );
		//this.label.format = new TextFormat( null, null, 0x000000 );
	}
		
		////////////////////////////////////////////////////////////////
	override protected function onRemoved():void
	{
		super.onRemoved();
		this.removeChild( this.cell );
	}
		
		////////////////////////////////////////////////////////////////
	override protected function drawLabel():void
	{
	super.drawLabel();
			
		if( this.data == null )return;
		this.cell.graphics.clear();
		this.cell.graphics.lineStyle( 1, 0x000000, 3 );
		this.cell.graphics.beginFill( this.data.color, 1 );
		this.cell.graphics.drawRect( 3, 5, this.width-7, this.height-10 );
		this.cell.graphics.endFill();
	}
		
		

  }
}