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
agaripian
Posts: 133
Registered: ‎12-02-2010
My Device: Z10 & Dev Alpha C

Re: BB10 Context Menu stops working

Maybe the context menu event listeners are getting destroyed when you remove the component? Why dont you just re-assign the context menu when you add the component? 

---------------------------------------------------------------------
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

I tried this too:

 

public function disableContextMenu():void
{
	if (actions)
	{
		// remove actions
		this.contextActions = null;
		this.removeEventListener(ActionEvent.ACTION_SELECTED, actionSelected);
	}
}
	
public function enableContextMenu():void
{
	this.contextActions = actions;
	if (!this.hasEventListener(ActionEvent.ACTION_SELECTED))
		this.addEventListener(ActionEvent.ACTION_SELECTED, actionSelected);	
}

Calling  component2.disableContextMenu before adding to parent, and component2.enableContextMenu after added to parent.


Does not help...

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

Re: BB10 Context Menu stops working

OK, I fixed it finally with this trick:

 

this.setChildIndex(prevComponent, 0);
this.setChildIndex(nextComponent, 1);

 So, I do not remove children from parent and context actiona are shown.

 

Of course, I'll have to check profiler for memory use in this case, but at least it did a trick for now.

Thanks to for idea about handlers removed when child removed from stage.

Please use plain text.