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
Deevych
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified
Accepted Solution

BB10 Context Menu stops working

Hello,

 

I got a problem with Context Menu not popping up after some steps I'm doing.

 

I have an app with UIComponents (in full-screen mode) changing using swipe, each component has it's own context actions set.

Components are changed on main view by add/removeChild.

Actions are created and initiated on app start.

 

Now, steps:

1. app start, component1 added to main view: context_menu1 works.

2. swipe from component1 to component2: context_menu2 works.

3. swipe from component2 to component1: context menu is not even popping out.

 

I tried to disable contextActions before changing components and enabling them for current component, but it did not work.

 

Any ideas how to fix this?

 

Thanks

Ivan

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10 Context Menu stops working

Does anything work when component1 is re-displayed or is it just the context menu?
Are you adding and removing the child element (component1, component2) to the parent sprite?
You can intercept the event prior to the context menu being displayed. Is that being fired?
Please use plain text.
Developer
Deevych
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified

Re: BB10 Context Menu stops working

Works all except of Context Menu.
Yes, add/remove child component to parent. But context actions are defined on component level (each one has its own actions).

Not sure how can I catch event BEFORE context menu shown?
I'm using action event on component level:
component.addEventListener(ActionEvent.ACTION_SELECTED, actionSelected);
Please use plain text.
Developer
Deevych
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified

Re: BB10 Context Menu stops working

Added ContextMenuEvent.OPENING listener - called on first cycle (when context works), no call on second cycle (no context).

So it's not a contextActions missing, but no OPENING event calling issue.
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10 Context Menu stops working

Can you post a sub-set of your code in how you are defining your context menu's?
Please use plain text.
Developer
Deevych
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified

Re: BB10 Context Menu stops working

[ Edited ]

On component level:

 

actionSet = new ActionSet();

var action:Action = new Action("Refresh", Assets.ICON_RELOAD, ACTION_REFRESH);
actionSet.actions = new <ActionBase>[action];
this.contextActions = actions;
if (!this.hasEventListener(ActionEvent.ACTION_SELECTED))
	this.addEventListener(ActionEvent.ACTION_SELECTED, actionSelected);

 

Also, here is the code how the components are changed, maybe this helps.

On parent level:

 

// components are created in array
arrComps.push(component1);
arrComps.push(component2);

// initial add
this.addChildAt(component1, 0);
currentComp = component1;

// move forward
this.addChildAt(component2, 1);
this.removeChild(component1);
currentComp = component2;

// same way moving back
this.addChildAt(component1, 1);
this.removeChild(component2);
currentComp = component1;

 This is very simplified snippet of whta I have in my app, but idea is as above.

 

So, again, when component1 is added to parent, Context Menu works, when moved to component2 - still works (showing correct menu from component2), but when move back to component1 - menu stops working, and even moveing forward again - no menu.

Please use plain text.
Developer
agaripian
Posts: 131
Registered: ‎12-02-2010
My Device: Z10 & Dev Alpha C
My Carrier: T

Re: BB10 Context Menu stops working

Are you assigning the context actions to your application or to your component? In your example you used "this.contextActions" what is "this" referring to? If you aren't assigning it to your components then try "component1.contextActions = actions"

---------------------------------------------------------------------
Developer of Stocks for Blackberry 10
Please use plain text.
Developer
Deevych
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified

Re: BB10 Context Menu stops working

Actions are assigned to components.

Sorry for confusion - it's copy/paste with some adjustments, but I mmissed to change this. to component.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10 Context Menu stops working

This is what I normally do, and I dont have any issues:

 

var csmenu :Vector.<ActionBase> = new Vector.<ActionBase>();
csmenu.push( new Action( 'Edit', new edit_icon(), {id:'edit'} ) );
csmenu.push( new Action( 'Add', new add_icon(), {id:'add'} ) );
			
var csset  :ActionSet = new ActionSet( csmenu, 'Event', '', new DeleteAction( 'Delete', null, {id:'delete'} ) );
var cssets :Vector.<ActionSet> = new Vector.<ActionSet>();
cssets.push( csset );
			
//
this.event_list.contextActions = cssets;
this.event_list.addEventListener( ActionEvent.ACTION_SELECTED, ActionSelected );
this.addChild( this.event_list );

 All done in the constructor of the page.

I think it might be how you are setting the ActionSet.

Give this a try to see if it makes a difference.

 

Please use plain text.
Developer
Deevych
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified

Re: BB10 Context Menu stops working

Thanks for suggestion, but it didn't work...

 

Again, the main problem is that context opens fine on initial component addition, but when add/remove component back and forward - it just stops opening up at all (even OPENING event is not fired).

Please use plain text.