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
Posts: 147
Registered: ‎09-10-2008
My Device: Not Specified

How to assign Accelerator Key ?

Hi All,

 

How can I assign Accelerator key to popup windows for Dialog.Ask function. (OK,Cancel) buttons in popup window. I want to set shortcut for OK button and Cancel button. How to achieve the shortcut functionality in the popup window. I have tried Button field in mainscreen using Key Listener it works fine. But I want to achieve the same thing in Popup window. Can any one suggest me thanks in advance..

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: How to assign Accelerator Key ?

Simply insert the Unicode "Combining Low Line" character (0x0332) after the character that you want to use as the shortcut. For example, "O\u0332K", "Ex\u0332it".
Developer
Posts: 43
Registered: ‎01-21-2009
My Device: Pearl 8100

Re: How to assign Accelerator Key (Key Board Shortcuts)?

[ Edited ]

I want to assisgn a key board shortcut (Accelerator) to a menu.

I added the unicode character as "MyM\u0332enu" but it did not work.

In the .rrc file the character shows an underline but on the 8100 simulator pressing the character "M" key did not work.

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: How to assign Accelerator Key (Key Board Shortcuts)?

I suggest you programmatically create a test menu item with "MyM\u0332enu" as its name. It might be that there's a problem with defining the underscore character in a resource file.

Developer
Posts: 43
Registered: ‎01-21-2009
My Device: Pearl 8100

Re: How to assign Accelerator Key (Key Board Shortcuts)?

Ok, I hardcoded "MyMenu" string and I can see an underscore now but still pressing 'M' is not doing anything.

Am I missing something?

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: How to assign Accelerator Key (Key Board Shortcuts)?

The shortcut should work once the menu is displayed (pressing M will select the "MyMenu" menu item). Are you by any chance trying to make it work when the menu is not displayed?

Highlighted
Developer
Posts: 43
Registered: ‎01-21-2009
My Device: Pearl 8100

Re: How to assign Accelerator Key (Key Board Shortcuts)?

No, I can see the menu with an under score.

I have added a menu like this on the message list main screen.

 

ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_MESSAGE_LIST , new ommCEmailListMenuItem(1,"File me\u0332ssage"));

 

I have Pearl 8100 model which has 'E' and 'R' on the same key. My menu "File message" opens a list box once clicked. When I am pressing 'E' the the selction is routing between "Reply" and "Reconcile Now" (because R is on the same key where the E is). It is no way selecting to my menu "File message".

 

I was expecting pressing 'E' will be equaivalent to clicking the menu and opening the list box which my menu does.

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: How to assign Accelerator Key (Key Board Shortcuts)?

Hm... I've just discovered that on my Bold 9700 with v5.0 handheld software, the menu shortcuts work only if the very first letter of the menu item is underscored... I suppose you're experiencing the same issue.

 

If you want the shortcut to work without opening the menu, you'll need to add some code into Screen.keyDown(). But that doesn't appear to be an option for you, since you are adding a menu item to another application...

Developer
Posts: 43
Registered: ‎01-21-2009
My Device: Pearl 8100

Re: How to assign Accelerator Key (Key Board Shortcuts)?

Even that did not work.

I am now using first letter 'F' as the underscored one but pressing F just traversing between File message, File, Forward As.

My OS is v4.2.1.103.

 

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: How to assign Accelerator Key (Key Board Shortcuts)?

May be the shortcut-via-underscore approach doesn't work for non-RIM application menu items (as opposed to conventional menu items that you add to your own application)...