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

Java Development

Reply
Developer
Posts: 65
Registered: ‎01-05-2010
My Device: Not Specified

Re: Preventing context menu from appearing on click?

Well I am back again Smiley Happy

 

My workaround didn't work, you see the problem with it (obvious really) is if I hold the click (press) for longer than the 100ms delay, the menu still appears.

 

This got me thinking however, and I believe I have now found the real solution, and it was so simple.

 

The menu is appearing because during click event, I remove the current manager and replace it with a new one.  The unclick event then fired (at the new manager) and ISNT being dealt with so the context menu appears.

 

To correct this issue, instead of responding to navigationClick() in my ListField class, I now respond to navigationUnclick(), navigationClick is ignored (default behaviour) and navigationUnclick is consumed, and because I switch managers after navigationUnclick is fired, it no longer gets the unclick event and no menu appears.

 

 

public class TableField extends ListField {
	protected boolean keyChar(char character, int status, int time) {  
	    if (character == Keypad.KEY_ENTER) {  
	        fieldChangeNotify(0);  
	        return true;  
	    }  
	    return super.keyChar(character, status, time);  
	}
	protected boolean navigationUnclick(int status, int time) {
	    fieldChangeNotify(0);  
		return true;
	}
}

 

 

 

Developer
Posts: 65
Registered: ‎01-05-2010
My Device: Not Specified

Re: Preventing context menu from appearing on click?

I have gone with the latter method, process the action in navigationClick() on the ListField and consume and ignore navigationUnclick() on the field manager(s).

Developer
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: Preventing context menu from appearing on click?

I had issues like these when i tried to dynamically remove fields/manager similar to your case.

A clean workaround i found was to reuse the same field/manager and replace the content inside to what you want to see.  if you want it to just get invisible then you can override subpaint/paint to paint it or not.

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
Posts: 65
Registered: ‎01-05-2010
My Device: Not Specified

Re: Preventing context menu from appearing on click?

All the managers that I am swapping are all based on the same custom manager which is based on VerticalFieldManager so its easy enough as it turns out to catch navigationUnclick() in there and consume it.

 

Such a complex problem (so it seemed) had such a simple solution.