BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   How do you HIGHLIGHT a menu item? (http://www.blackberryforums.com/developer-forum/114728-how-do-you-highlight-menu-item.html)

kberry 01-26-2008 01:57 PM

How do you HIGHLIGHT a menu item?
 
How do you simply HIGHLIGHT whatever menu item you want
from within your own BB application?

The RIM Class MenuItem documentation Field summary shows
static int flags like 'SELECT' and 'CANCEL_SELECT' but the
Method summary for the class doesn't give you a clue what,
if anything, you can do with these commands.

The 'Menu' class ( Parent class for MenuItem? ) has the
obvious setDefault() and setItemHighlight() methods but
how do you just simply 'call' these parent Class 'Menu'
methods from within your own application?

Would it be some kind of 'super.setDefault()' call from
within the constructor of your own 'MenuItem'?

All I want to do is the same thing I see native RIM apps doing.

If I have added screen jump menu items to my own application
menu that lets the user go from screen to screen within the (same)
application then whatever screen the person is currently on...
when they press the MENU button again the last menu item
chosen should stay HIGHLIGHTED until they pick another menu
item and jump to another screen.

This ought to be simple. What am I missing here?

kberry 01-26-2008 03:14 PM

Answering my own question here...

What I appear to missing are brain cells.

When 'makeMenu' is called you then have a pointer to 'menu'
and anywhere within the 'makeMenu' override while you are
creating your MenuItems you can just call...

menu.setDefault( (MenuItem) my_menu_item );

If you want to set/change the default menu item AFTER
'makeMenu' or at some other run-time point within your
application then all you have to do is 'remember' what
the last 'menu' handle was passed to the last 'makeMenu'
method.

Create yourself a 'global' that can seen from all 'screens'
such as...

static Menu _menu = null;

...and then every time 'makeMenu' is called anywhere
in your application just update it with the 'Menu'
pointer being passed to you by 'makeMenu'...

_menu = menu;

Then, from anywhere in your application, as long as you
have also saved the 'MenuItem' handles for your own
menu items saved to globals as well you can just call...

_menu.setDefault( (MenuItem) my_menu_item );


All times are GMT -5. The time now is 02:51 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.