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
Regular Contributor
Posts: 68
Registered: ‎03-15-2011
My Device: 9630
My Carrier: 3G

Popup menu showed when touch in ObjectListField on some versons 9800.

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)?

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Popup menu showed when touch in ObjectListField on some versons 9800.

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.

 

 

Regular Contributor
Posts: 68
Registered: ‎03-15-2011
My Device: 9630
My Carrier: 3G

Re: Popup menu showed when touch in ObjectListField on some versons 9800.

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-Development/Button-Click-opens-the-Blackbery-Menu/m-p/47... :

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...