You’re a smart guy, figure it out!

Mike Grushin’s thoughts on everything tech-related and more…

BlackBerry JDE 4.2, ButtonField and disabling ContextMenu

Posted by mikeg on May 14, 2009

I’ve been playing around with BlackBerry JDE 4.2 for some time now and while using the simulator I would “click” on buttons using the Enter key. When I finally installed on the physical device I found that it is more intuitive to click on the button using the ball while moving around the screen. The problem is that by default it brings up a context menu which produces undesirable result:

image

Looking at API and doing a few google searches led me to implementing a subclass where I was planning to override either getContextMenu() or makeContextMenu(), but for some reason those methods were not being called. A few more random searches and turns out that you can pass ButtonField.CONSUME_CLICK and that will eliminate the undesirable display of the context menu.

Here is excerpt from API that fails to mention CONSUME_CLICK

ButtonField
public ButtonField(String label,
                   long style)Constructs a new ButtonField instance with provided label and style.
Provided a label string to show, and a style, this method builds a button field using your style.

Parameters:
label – Label string for the button.
style – Field style for the button: can be a combation of any generic field style, BARE, DrawStyle.ELLIPSIS, Field.FOCUSABLE and Field.NON_FOCUSABLE

Advertisement

2 Responses to “BlackBerry JDE 4.2, ButtonField and disabling ContextMenu”

  1. 4h34d said

    Fixed my issue, that was useful! Thanks!

  2. Techno King…

    [...]BlackBerry JDE 4.2, ButtonField and disabling ContextMenu « You’re a smart guy, figure it out![...]…

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.