views:

790

answers:

3

I'm running into the following scenario on some devices: when the use clicks on field and expects an response, instead of properly responding to that click event, the device shows the context menu at the bottom center of the screen.

navigationUnclick and trackwheelUnclick
From what I've read, I can override navigationUnclick and trackwheelUnclick to prevent the menu from showing. I'm doing this as the screen level but reproducing the centered-menu scenario is difficult. Is this the correct approch?

Why does this happen? Is there any way to resolve this?

+1  A: 

Can you post your code? Try overriding trackwheelClick and navigationClick instead of the Unlick methods. Also make sure you return true in these methods.

Jan Gressmann
+1  A: 

If you override onMenu and just return true (you handled the menu event) then the menu will not show up...assuming you don't need a full menu either - if you want full menu and not context menu then just do what Jan said and you should be fine - make sure to return true or else the event will bubble up and end up with the menu being generated

public class MyClass Extends MainScreen
{
   ///
  // Override onMenu to prevent menu from coming up when you click trackwheel 
  public boolean onMenu(int instance)
  {
    return true;
  }
}
JustinD
+4  A: 

I recently had this happening. I was extending MainScreen to provide some basic functionality, but didn't want the context menus. Returning true from navigationClick() removed this behavior.

public class MyScreen extends MainScreen {
    protected boolean navigationClick(int status, int time) {
        /*  
        ... custom behavior ... 
        */
        return true;
        // the following line would trigger the context menu
        //return super.navigationClick(status, time);
    }
}

I didn't need to override navigationUnclick() at all. Unlike @JustinD's approach with override onMenu(), this only prevents the menu from this certain case -- not across the entire screen (which you may want, and that would probably be a better way to do it).

Anyway, that's been my experience with clicks and menus recently.

lilbyrdie
This is great, very concise and works perfectly!
AtariPete
+1 It should be noted though that returning true specifies that the event has been consumed and no other listeners should process the event. That's why the menu won't be displayed.
Fostah