6

In my application there is a button and when the button is clicked the context menu pops up. How can I avoid having the context menu show up?

protected void makeMenu(Menu menu, int context){
    menu.add(_imageMenuItem);
    super.makeMenu(menu, context);
}

class ImageMenuItem extends MenuItem {      
    ImageMenuItem() {
        super("Login Screen", 0, 0);            
    }
    public boolean onMenu(int i) {
        return false;
    }

    public void run() {
        UiApplication app = (UiApplication) getApplication();
        app.pushScreen(new LoginScreen());
    }
}
Michael Donohue
  • 11,606
  • 5
  • 29
  • 44
Jisson
  • 2,915
  • 7
  • 34
  • 67

1 Answers1

16

have you added style to the ButtonField via the constructor?

ButtonField button = 
    new ButtonField("text", Field.H_CENTRE|ButtonField.CONSUME_CLICK);
Michael Donohue
  • 11,606
  • 5
  • 29
  • 44
Adil Soomro
  • 36,617
  • 9
  • 98
  • 146
  • Yea Adil,I added style to the ButtonField via the constructor I late to comment since I am out of station sorry – Jisson Feb 08 '11 at 04:54
  • btnSave=new ButtonField("Save",FIELD_HCENTER | FIELD_HCENTER); – Jisson Feb 08 '11 at 04:56
  • Thanks Adil,I got the solution ....when I added ButtonField.CONSUME_CLICK to the consructor . – Jisson Feb 08 '11 at 04:59
  • I have the same problem for a verticalfield manager, Do you have idea to resolve it? – Jisson Feb 08 '11 at 16:06
  • My application uses a vertical field manager: scrollingRegion = new VerticalFieldManager(USE_ALL_HEIGHT| VERTICAL_SCROLL | VERTICAL_SCROLLBAR|USE_ALL_WIDTH);CustomField customField = new CustomField(hashtable, int);scrollingRegion.add(customField); add(scrollingRegion); My app run in the way that user click in a button the add(scrollingRegion) code is performed ,and he can see some row of information ,When user click on each row the menu is displayed ... If you have idea plz help – Jisson Feb 10 '11 at 07:47
  • Sounds the problem is in ur customField, which your are using like a button i think, Have you properly overridden the fieldChangeNotify() method, in case you are using the CustomField as button? – Adil Soomro Feb 10 '11 at 09:53
  • No Adil, I am not using custom field as a button ,There is a button say(btnShow) in my app and a vertical field manager,My customField is a calss which extends ListField implements ListFieldCallback and there is a table row manager and different row(in a single row there is 4 listfields) are dynamically populated using a for loop .And the newly created customField Object is adding to the verticalfield manager and finally vertical field manager is adding to the main screen. – Jisson Feb 10 '11 at 10:04
  • Ok i got it. Now tell me what type of action you want to perform when the user clicks at any row of your listfield..? – Adil Soomro Feb 10 '11 at 11:07
  • No any action take place when user clicks listfield.Now It showing the menu – Jisson Feb 10 '11 at 11:35
  • @AdilSoomro I am facing same issue but your answer not resolving my issue.. still facing same... :/ – SilentKiller Jun 21 '14 at 05:46