BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 04-15-2010, 02:11 AM   #1 (permalink)
New Member
Join Date: Apr 2010
Model: 8310
Carrier: 4.1.0
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default ContextMenu : unable to achieve on JDE 4.1 and below : some items are displayed twice

Please Login to Remove!

Hi all,

I am working on the Menu and Context Menu currently.For an edit field,I want to add a menu item "Search" on its context menu.I created a custom edit field, and over-rided the makeContextMenu() to add the "Search" item. In my Screen class, i over-rided the makeMenu() and handled it as below :

protected void makeMenu(Menu menu, int instance) {
		super.makeMenu(menu, instance);

		if (instance == Menu.INSTANCE_DEFAULT) {

			menu.add(new MenuItem("Login", 20, 10) {
				public void run() {

		} else if (instance == Menu.INSTANCE_CONTEXT) {
			// context menu handling :

			Field focussedField = UiApplication.getUiApplication()
			if (focussedField != null) {
				ContextMenu cm = focussedField.getContextMenu();
				if (!cm.isEmpty()) {
My customEditField looks like :

protected void makeContextMenu(ContextMenu contextMenu) {
		contextMenu.addItem(new MenuItem("MyeditField 1", 10, 2) {

			public void run() {

I got this solution from the BLB support forum, and it works fine for JDE 4.2 and above.

However, I am trying to achieve the same on JDE 4.1 and below also.

I tried a simple workaround, by replacing the Menu.INSTANCE_CONTEXT and Menu.INSTANCE_DEFAULT with thier actual values since these constants have been included only since JDE 4.2

I was able to achieve the context menu properly, but when i try to paste some selected and copied text, I get the "Paste" item twice in my context menu, although it is displayed only once in the main menu.

I suppose I have to include handling for Menu.INSTANCE_CONTEXT_SELECTION also, but am clueless about how to handle it..

Also, if anyone can suggest a cleaner way of achieving it in JDE 4.1 or below, it would be really great..


Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.