avoid showing menu on button click
Asked Answered
Y

1

6

In my application there is a button and when the button is clicked, the context menu poping 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());
    }
}
Yellowish answered 7/2, 2011 at 7:0 Comment(0)
E
16

have you added style to the ButtonField via the constructor?

ButtonField button = 
    new ButtonField("text", Field.H_CENTRE|ButtonField.CONSUME_CLICK);
Eelworm answered 7/2, 2011 at 11:29 Comment(10)
Yea Adil,I added style to the ButtonField via the constructor I late to comment since I am out of station sorryYellowish
btnSave=new ButtonField("Save",FIELD_HCENTER | FIELD_HCENTER);Yellowish
Thanks Adil,I got the solution ....when I added ButtonField.CONSUME_CLICK to the consructor .Yellowish
I have the same problem for a verticalfield manager, Do you have idea to resolve it?Yellowish
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 helpYellowish
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?Eelworm
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.Yellowish
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..?Eelworm
No any action take place when user clicks listfield.Now It showing the menuYellowish
@AdilSoomro I am facing same issue but your answer not resolving my issue.. still facing same... :/Lovelady

© 2022 - 2024 — McMap. All rights reserved.