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
New Developer
vvtechser
Posts: 18
Registered: ‎03-10-2009
My Device: Not Specified

Trackball click, instead of responding to event, context menu is shown. Why?

[ Edited ]

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.

 

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?

 

 

 

Message Edited by vvtechser on 08-17-2009 03:39 PM
Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Trackball click, instead of responding to event, context menu is shown. Why?

[ Edited ]

You need to override navigationClick, not navigationUnclick or trackwheelUnclick. Code like this should do the trick:

 

protected boolean navigationClick(int status, int time) {
// only override menu behavior for unmodified click
if ((status & KeypadListener.STATUS_ALT) == 0 &&
(status & KeypadListener.STATUS_SHIFT) == 0)
{
// respond to click here
return true; // suppresses showing of context menu
}
return super.navigationClick(status, time);
}

 

 

 

Message Edited by Ted_Hopp on 08-17-2009 09:02 PM



Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Trackball click, instead of responding to event, context menu is shown. Why?

If this occurs on a ButtonField, you should add the style CONSUME_CLICK to the field.

 

Contributor
malbito
Posts: 12
Registered: ‎05-27-2010
My Device: storm

Re: Trackball click, instead of responding to event, context menu is shown. Why?

Thank you so much for this snippet. It only took me a couple of days** ! thanks again :smileyhappy:

Contributor
malbito
Posts: 12
Registered: ‎05-27-2010
My Device: storm

Re: Trackball click, instead of responding to event, context menu is shown. Why?

One question why use the bitwise AND operator.. == 0

 

If i'm not mistaken, you are comparing every bit of the integer status and the keypadListener.Status_Alt. if at least one bit is not the same it will return a 0.

 

Why not just simply use the != operator. 

 

I think there is an implicit cast from int -> long

 

so doing the  int != long would eventually yield a long != long

 

... just wondering.. 

 

Thanks.

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Trackball click, instead of responding to event, context menu is shown. Why?

Hopefully this will explain the use of the bitwise operation and == 0

 

1100 & 0100 will give 0100, which is not equal to 0

1100 & 0001 will give 0000, which is equal to 0

 

but

 

1100 != 0100 is true, and

1100 != 0001 is true too

 

Does that make sense?

 

 

Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Trackball click, instead of responding to event, context menu is shown. Why?

[ Edited ]

@malbito -- I'm not sure where you see an implicit cast to long. Everything is an int, and the & operator returns an int if both args are int.

 

Peter has a good explanation of the use of the & operator. I'd just add that your statement "if at least one bit is not the same it will return a 0" is incorrect. Rather, the operator works bit-by-bit -- each bit of the result is the logical and of the corresponding bits of the two arguments. The result will be non-0 if there is at least one bit position at which both arguments have a 1.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Contributor
malbito
Posts: 12
Registered: ‎05-27-2010
My Device: storm

Re: Trackball click, instead of responding to event, context menu is shown. Why?

thanks, it makes sense.