BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 09-22-2009, 10:52 PM   #1 (permalink)
New Member
 
Join Date: Sep 2009
Model: 8330
PIN: N/A
Carrier: Sprint
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Menu Position Change

Please Login to Remove!

Hi Everyone:

I've been trying to get the menu button to display a context menu in my application. I have multiple screens, and I have a ui class handling listening for key presses like so:

Code:
                else if (key == Keypad.KEY_MENU) 
                {
                    // menu key was pressed
                    Menu m = parent.getActiveScreen().getMenu(0);
                    m.show();
                }
Now, I also have the following, on a specific screen ("options" screen of my application):

Code:
    private MenuItem saveData = new MenuItem("Save", 110, 10) 
    {
        public void run() 
        {
            // perform saving functionality
        }
    };
    
    private MenuItem cancel = new MenuItem("Cancel", 110, 10)
    {
        public void run()
        {
            // cancel by popping the screen off the stack
            Screen currentScreen = getUiEngine().getActiveScreen();
            getUiEngine().popScreen(currentScreen);
        }
    };
        
    public OptionsMenu()
    {       
        // We set the title on the screen
        LabelField title = new LabelField("Application Options", LabelField.FIELD_HCENTER);
        setTitle(title);
         
        addMenuItem(saveData);
        addMenuItem(cancel);
    }
It works ok, but there are two problems: 1) The menu displays in the upper right corner of the screen, and I'd like it to display in the bottom left corner of the screen, like other BB applications, and 2) if I have the menu open, and press the menu key again, it opens another menu (I can't tell what it says, because it's rendered off screen). I'd like to disable this multiple menu situation.

Can someone give me some idea of what I'm doing wrong? I've tried searching google, as well as reading through API docs, but can't seem to find what I'm looking for.

Thanks in advance,

~Jwir3
Offline  
Old 09-23-2009, 04:19 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Sep 2009
Model: 8100
PIN: N/A
Carrier: Airtel
Posts: 75
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

If u are using the menu.show() api, then the Menu will be rendered on the Right-Top corner only...
Menu can be shown at the Left-Bottom corner (depending upon the Device) only when the device handles the menu rendering... u can achieve it by using the makeMenu() method of the screen...
Offline  
Old 09-23-2009, 04:06 PM   #3 (permalink)
New Member
 
Join Date: Sep 2009
Model: 8330
PIN: N/A
Carrier: Sprint
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi. Thanks for the reply.

So, what would be the proper way to call makeMenu() from within my keyDown method? Could I do something like this:

Code:
    else if (key == Keypad.KEY_MENU) 
                {
                    // menu key was pressed
                    Menu m = parent.getActiveScreen().getMenu(0);
                    parent.getActiveScreen().makeMenu(m,0);
                }
Or is there another way?

Thanks,

~Jwir3
Offline  
Old 09-24-2009, 02:15 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Sep 2009
Model: 8100
PIN: N/A
Carrier: Airtel
Posts: 75
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

if you are using this method, then u r not supposed to take care of Menu rendering... leave it on BB device to do it for you... you just check for the Menu Key Event and if it is there then do not consume the key event.... BB platform itself call the makemenu() method to render the menu...
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.