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
Developer
austinfrance
Posts: 65
Registered: ‎01-05-2010
My Device: Not Specified
Accepted Solution

Preventing context menu from appearing on click?

I get the context? menu (the one with Show/Hide keyboard, and Full Menu options) when I press (touchscreen) or click a field in a FieldList.  I don't know why.

 

I extended ListField as follows:

 

public class TableField extends ListField {
	TableFieldCallback callback;
	public void setTableCallback(TableFieldCallback callback) {
		this.callback = callback;
	}
	protected boolean trackwheelClick(int status,int time) {
		App.DEBUG("CLICK START " + time);
		if (null != callback) callback.onclick(this.getSelectedIndex());
		App.DEBUG("CLICK CONSUMED");
		return true;
	}
}

The Field Manager that contains this field implements TableFieldCallback and sets the callback object.

 

The list field does not contain any child fields, rather the "data" is drawn for each field.

 

I press (click) a field (row) in the field list and trackwheeClick() is called which calls my onclick() method in my object and is processed (it loads another view), however the context menu is also being displayed, even tough I returned true from trackwheelClick() signaling that I consumed the event.

 

This behaviour is ofc unacceptable, I need a way to be able to disable the context menu when the field is clicked.

 

Note: sometimes the full menu appears but I assume that's because I also accidentally click / press the full menu option in the resulting context menu... perhaps its because the context menu gets the release event from the press/click don't know.

 

 

 

Please use plain text.
Developer
JCarty
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: Preventing context menu from appearing on click?

[ Edited ]

Try changing from trackwheelClick to navigationClick. trackwheelClick is depreciated.

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Please use plain text.
Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: Preventing context menu from appearing on click?

return true from navigationclick.

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Please use plain text.
Developer
austinfrance
Posts: 65
Registered: ‎01-05-2010
My Device: Not Specified

Re: Preventing context menu from appearing on click?

[ Edited ]

I have tried using navigationClick() instead (basically renaming trackwheelClick to navigationClick()) and it's still doing it.

 

What I have is several layers of VerticalFieldManagers/HorizontalFieldManagers then a ListField in one of those managers.

 

A | VerticalFieldManager
B | -> VerticalFieldManager      (taking up most the display)
C | --> VerticalFieldManger      (taking up 50px at top of display)
D | --> VerticalFieldManager     (taking up rest of its container
                                   - ie main part of display)
E | ----> VerticalFieldManager   (taking up all its container)
F | -------> ListField           (taking up all its container)
G | -> HorizontalFieldManager    (70px hight at bottom of display)
H | ---> CustomField
I | ---> CustomField
J | ---> CustomField
K | ---> CustomField
L | ---> CustomField

Focus starts in the HorizontalFieldManager (G) on one of the CustomFields (H), the following sequence happens:

 

1. Press one of the ListField (F) entries (rows).

2. The Show Keyboard/Switch Application/Full menu appears

3. I press the list field entry again

4. The Show keyboard/Switch Application/Full menu disappears

5. I press the list field entry a third time

6. navitationClick() (or trackwheelClick) is called on my ListField

7. the program swaps in another Manager in place of E, i.e. it deleteAll() from (D) and adds a new possibly different kind of (E)

8. I return true from navigationClick() (to consume the click)

9. the full menu appears over the screen (and new manager)

 

Ok, so I can kind of understand the first menu popping up, because my program didnt trap and process the press.  What received the press (click) event?

 

But why when I return true from navigationClick() is a full menu still displayed?

 

 

 

Please use plain text.
Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: Preventing context menu from appearing on click?

hey for touch return true on nothandled unclick also

and for non touch returning true from not handled navigationClick should do the job.

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Please use plain text.
Developer
austinfrance
Posts: 65
Registered: ‎01-05-2010
My Device: Not Specified

Re: Preventing context menu from appearing on click?

Hi thanks for the response. What do you mean not handled navigationClick? Do you mean I need to override navigationClick in every single manager class in the hierarchy and return true? i.e on objects A through L?
Please use plain text.
Developer
austinfrance
Posts: 65
Registered: ‎01-05-2010
My Device: Not Specified

Re: Preventing context menu from appearing on click?

[ Edited ]

From some tests I just performed, i.e. I added navigationClick and trackwheelClick it would seem the default implementation of these for a Manager is to return true (consume) the click.

 

Specifically I had a horizontalfieldmanager (G) with some custom fields (H-L) inside. I originally was not overriding these methods, and trapping clicks via navigationClick() on the custom field, and that was working, no extra unwanted menu. If I override the navigationClick() and trackwheelClick() methods on the manager containing those fields and return false, the full menu then appears. return true and the menu disappears again.

 

So the default implementation on a manager for navigationClick() and trackwheelClick() would seem to be to return true (consume the click). So I should not need to add these methods to my managers. Good, because I wasn't.

 

I am already returning true from navigationClick() on my custom ListField so I don't understand why I see the menu when I press it.

Please use plain text.
Developer
filiussoft
Posts: 106
Registered: ‎06-18-2009
My Device: Bold

Re: Preventing context menu from appearing on click?

Are you CustomFields buttons? if so, extends the ButtonField and pass CONSUME_CLICK as a style to the constructor.

 

In regards to the ListField, my list fields are based on ObjectListField and as long as I return true from navigationClick, I dont get the contextual menu. I saw that your ListField is taking up all the height so it is not possible that you are clicking in an unhandled region.

During debug, do you see the click coming through your navigationClick method?

----
If this helped you, press the thumbs up button (on the far right - '+' thumb icon)
If this post solved the issue, click "Accept as Solution"
Please use plain text.
Developer
austinfrance
Posts: 65
Registered: ‎01-05-2010
My Device: Not Specified

Re: Preventing context menu from appearing on click?

[ Edited ]

Grr this is annoying.  Ok, if I do the following:

 

 

	protected boolean navigationClick(int status, int time) {
		return true;
	}
	protected boolean navigationUnclick(int status, int time) {
		return true;
	}
	protected boolean trackwheelClick(int status, int time) {
		return true;
	}
	protected boolean trackwheelUnclick(int status, int time) {
		return true;
	}

 I don't get the full menu popping up, neither do I get a response to my click (i.e. because I don't call my callback).  If I change this to

 

 

	protected boolean navigationClick(int status, int time) {
		if (null != callback) callback.onclick(this.getSelectedIndex());
		return true;
	}
	protected boolean navigationUnclick(int status, int time) {
		return true;
	}
	protected boolean trackwheelClick(int status, int time) {
		return true;
	}
	protected boolean trackwheelUnclick(int status, int time) {
		return true;
	}

 The press is actioned, but I also now get the full menu.  The only difference is the call to callback.onclick(this.getSelectedIndex());

 

What callback.onclick() does is create a new manager, remove the current manager (F) from its container (E), and adds the new manager (F) to container manager (E).  The removed manager is not destroyed, just removed from the display.

 

 

Please use plain text.
Developer
austinfrance
Posts: 65
Registered: ‎01-05-2010
My Device: Not Specified

Re: Preventing context menu from appearing on click?

[ Edited ]

> During debug, do you see the click coming through your navigationClick method?

 

Yes, my custom ListField navigationClick() is getting called.

 

I wonder if should I defer calling callback.onclick() until after this event has completed, perhaps its because I remove the Manager+ListField from the display and add a new Manager (with its own content) during the click event that is confusing things.

Please use plain text.