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
Blanc
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: How can I disable the default ContextMenu?

pass ButtonField.CONSUME_CLICK as a style parameter to the fields which you are adding to manager/screen. it will solve the issue.

Thanks and Regards,
PraveenGoparaju.
Please use plain text.
Developer
Blanc
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: How can I disable the default ContextMenu?

Pass ButtonField.CONSUME_CLICK style parameter to the fields.

Thanks and Regards,
PraveenGoparaju.
Please use plain text.
Contributor
souravbasu2k
Posts: 15
Registered: ‎09-06-2010
My Device: Not Specified

Re: How can I disable the default ContextMenu?

I have a screen which contains some LabelField(s) that are FOCUSABLE. I want to override the default Context Menu & add ONLY two menu items "Open" & "Delete". I'm using the following code:

 

protected void makeMenu(Menu menu, int instance) {

     Field focus = UiApplication.getUiApplication().getActiveScreen().getLeafFieldWithFocus();

 

     if (  (focus != null)  &&  (focus instanceof LabelField)  ) {            
            menu.add(new MenuItem("Delete Item", 10, 20) {
                public void run() {
                    delete_item();
                }
            });
            menu.add(new MenuItem("Open", 20, 10) {
                public void run() {
                    open();
                }
            });   
   
     }

}

 

But I'm still getting the "Copy" option when the LabelField gets the focus. Any idea why?

 

Thanks

Please use plain text.
Contributor
souravbasu2k
Posts: 15
Registered: ‎09-06-2010
My Device: Not Specified

Re: How can I disable the default ContextMenu?

I'm still waiting for some guidance.

Please use plain text.
New Contributor
nagumitti
Posts: 8
Registered: ‎02-18-2013
My Device: 8700,9300,8520,Blackberry Z10
My Carrier: BB

Re: How can I disable the default ContextMenu?

public boolean trackwheelClick(int status,int time)
{
Menu menuObj = new Menu();
makeMenu(menuObj,0);
menuObj.deleteItem(0);
menuObj.show();
return true;
};

menuObj.deleteItem(0); it will delete 0th position of menu item...

Please use plain text.