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: 17
Registered: ‎03-03-2009
My Device: Not Specified
Accepted Solution

Dismissing the system menu while in a MIDlet?

Hello.  I am working on a Bold, which runs OS version 4.6.0.

 

While in a MIDlet, the user holds the device menu key.  A system menu appears with "Close" as the only choice.

 

I would like to allow the user to dismiss this menu once it appears, perhaps using the Back key, but I am unsure how to know it is there.

 

I found this article about how to hide the system menu entirely:

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800256/...

 

But there was a clause in there that said it was not possible to hide the "Close" menu item from a MIDlet.

 

How can a MIDlet dismiss that menu?

 

Thanks.

 

 

 

Developer
Posts: 17
Registered: ‎03-03-2009
My Device: Not Specified

Re: Dismissing the system menu while in a MIDlet?

Okay, so, is the thing that pops up in the bottom left corner when you hold down the device key a Menu?  As in, is it a net.rim.device.api.ui.component.Menu ?

 

I thought it might be, so I tried to call close() on it during my keyUp event.  I tried doing a getMenu(0) on what I hoped was the active Screen, and I definitely get a non-null Menu returned.  But calling menu.close() did not dismiss the little menu on my screen, and when I tried getting the default MenuItem, it printed out "<Empty Menu>".

 

 

net.rim.device.api.ui.component.Menu menu = net.rim.device.api.ui.Ui.getUiEngine().getActiveScreen().getMenu(0);
if (menu != null) {
	net.rim.device.api.ui.MenuItem item = menu.getDefault();
	String itemStr = "NADA!";
	if (item != null) {
		itemStr = item.toString();
	}
	System.out.println(" Closing menu! " + itemStr);
	menu.close();
}

 

 

Am I wrong about the "Close" popup menu being this kind of menu?  Is there another approach I can take to get it?  Again, this is a MIDlet I'm working in, in case that matters.

 

Thanks.

 

 

Developer
Posts: 17
Registered: ‎03-03-2009
My Device: Not Specified

Re: Dismissing the system menu while in a MIDlet?

I found something that seems to work.

 

The Menu wasn't what I thought it was, but I discovered that when the menu is showing, the type of Screen is net.rim.device.api.ui.menu.DefaultMenuScreen.  So during the key press events, I can see if the active Screen is of this type, and if so, I can call screen.close() on it.

 

It's a little hacky but I didn't find any other way to get at it.  And it seems to solve my problem.

New Developer
Posts: 16
Registered: ‎11-30-2009
My Device: Bold 9780

Re: Dismissing the system menu while in a MIDlet?

I'm faced with a similar problem (trying to display a screen and simulate a full keyboard lock) and am trying to implement your approach. Where did you add the screen.close() and how to did you get a handle to the screen object? If you could please provide just a little more detail I would greatly appreciate it.

 

Thanks 

---------------------------------------------------------------------------------
Don't forget to give Kudos where appropriate :smileyhappy:

Get email accident protection with ReplyGuard!