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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


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

BB10: Adding context menu to list

In case this is useful to someone.  Little bit of a pain to setup, but it works:

 

// build menu
var csmenu :Vector.<ActionBase> = new Vector.<ActionBase>();
csmenu.push( new Action( 'Edit'	, new edit_icon()	, {id:'edit'} ) );
csmenu.push( new Action( 'Map'	, new map_icon()	, {id:'map'} ) );
			
var t:ActionSet = new ActionSet( csmenu, 'Your Title Here', '', new DeleteAction( 'Delete', new trash_icon(), {id:'delete'} ) );

var sets :Vector.<ActionSet> = new Vector.<ActionSet>();
sets.push( t );

// set to list
this.poi_list.contextActions = sets;
this.poi_list.addEventListener( ActionEvent.ACTION_SELECTED, ActionSelected );

// ...

//////////////////////////////////////////////////////////////////////////////
private function ActionSelected( event : ActionEvent ) : void
{
  switch( event.action.data.id )
  {
	case 'edit'   : this.EditPoi(); break;
	case 'delete' : this.DeletePoi(); break;
	case 'map'    : this.gotoMap(); break;
  }
}

 

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

Re: BB10: Adding context menu to list

To know which item is selected, use the list's selectedItem attribute. It is best to check if this is null before proceeding since it appears that in some cases, it get set to null during the context menu selection is shown.
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10: Adding context menu to list

WTH: 5000th post!
Developer
Developer
Posts: 227
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: BB10: Adding context menu to list

Thanks, I did get it working too, though I did wonder why "contextActions" is a "Vector"?  When/How would any set other than the first be activated?

 

Regards,

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

Re: BB10: Adding context menu to list

Vector force the type of object to be in it, where Array you can have anything. Though not important here, Vector's are faster to traverse then Array's and are good to use where yo uhave a large number of items in it. It's better programming, but the syntax is a little ugly (think C++ templates).
Developer
Developer
Posts: 227
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: BB10: Adding context menu to list

Vector vs Array not the question:

 

why more than 1 ActionSet?

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

Re: BB10: Adding context menu to list

I have no idea. That is how the API is. I'll see if I can get clarification.
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10: Adding context menu to list

The multiple ActionSets are there to mimic the Cascades API. It allows you to cycle thru the context menu (different state conditions). However, only the first one is ever used at this time. It is there for future design considerations.
Developer
Developer
Posts: 227
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: BB10: Adding context menu to list

understood - thanks for the clarification.

Developer
Posts: 133
Registered: ‎12-02-2010
My Device: Z10 & Dev Alpha C
My Carrier: T

Re: BB10: Adding context menu to list

Thanks for this! But is it possible to add  a context menu to a Flex List instead? Have you been able to do this? Can I make the context menu appear without associating it to a list?

---------------------------------------------------------------------
Developer of Stocks for Blackberry 10