10-23-2011 08:47 AM
In my ObjectListField, I want to let the "short menu (os 5)" and "popup menu (os 6)" appear if the user clicked or touched one item and if there's no default operation (when navigationClick(int, int) returns false). So I add a method to the ObjectListField:
public ContextMenu getContextMenu(int instance) {
if (instance == 0) {
return getContextMenu();
} else {
ContextMenu contextMenu = ContextMenu.getInstance();
contextMenu.setTarget(this);
makeContextMenu(contextMenu);
return contextMenu;
}
}It seems that the os will automatically invoke it and so a "popup menu" is created. I think a "popup menu" should not appear if navigationClick() returns true(consumed).
On 9800(6.0.0.396) and 9810 it works as I expected. But on some versions 9800 (have tested on 6.0.0.546, 6.0.0.570) the popup menu appears even when I touched an item and there's an operation (navigationClick() returns true). And the strange thing is that the pop up menu not appear every time (although the most time).
So how to make it works as I expected (when navigationClick() returns false the pop up menu should appear)?
10-23-2011 01:48 PM
Touch events do not activate navigationClick(int, int) but instead they activate the touchEvent function.
You should override this function with your preffered guesture.
navigationClick(int, int)is activated when clicking on the pad.
E.
10-23-2011 02:17 PM
No, touch event will invoke navigationClick(int, int) if the touch event is not consumed, you can find that if you make a debug.
I don't know how to quote in this bbs, so I just copied http://supportforums.blackberry.com/t5/Java-Develo
For the navigationClick and touch event interaction: After some experiment I found that:
- If touchEvent of the field where user click return true then the touch event is consumed and there is no navigationClick anymore.
- If touchEvent return false, then API will convert it into navigationClick (I don't know exactly how this happens). However, be careful that:
+ First the Screen.navigationClick() is call
+ By default this method implementation will call ScreenDelagateManager.navigationClick()
+ Be default implementation, delegate manager will call navigation click of currently focused field.
If the field on which user click is not FOCUSABLE then that field will not receive navigationClick()
And for my own problem, I have to say it's a very strange question that only certion version os will encounter this (maybe because I add that method), but I made a fix:
in navigationClick(int, int):
boolean consumed = false;
// logic here...
if (consumed) {
if (Touchscreen.isSupported() && DeviceInfo.getSoftwareVersion().startsWith("6")) {
// avoid wrong popup menu apperas when touch one item
getScreen().setContextMenuProvider(new DefaultContextMenuProvider());
// restore, so the popup menu will appear when touch and hold on screen and or hold the touchpad
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
getScreen().setContextMenuProvider(null);
}
});
}
return true;
}but another problem appears in my application on 6.0.0.396, so i am still testing...