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
behrk2
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified
Accepted Solution

Trouble invoking makeMenu() from a separate non-Screen class

[ Edited ]

Hello,

 

I have the following classes:

 

 

public class QueueScreen extends MainScreen{}

 

 

 

public class GetQueue {

QueueScreen screen;

public GetQueue(QueueScreen screen){
this.screen = screen;
}
}

 

The GetQueue class ultimately updates the UI of the QueueScreen by adding adding a new instance of the same ButtonField to the screen multiple times with screen.add().  What I am looking to do is when one of those buttons has focus, add a particular Menu Item with makeMenu() from within the GetQueue class.

 

To re-iterate with an example: With the GetQueue class, I am adding the same button to the QueueScreen many times (and uniquely identifying the button with setCookie()). Each time one of those buttons is highlighted, I want to add a particular menu item to QueueScreen.

 

I have tried adding a makeMenu() method in QueueScreen and then accessing the method from getQueue. This did not work, however. The only potential way I can think of is to use screen.addMenuItem() when the ButtonField has focus, and then removeMenuItem when the ButtonField does not have focus. I could not get this to work either, because each button is essentially the same (only differing in its cookie).

 

What is the best way to accomplish this? Thanks.

 

 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Trouble invoking makeMenu() from a separate non-Screen class

I like this idea.

"use screen.addMenuItem() when the ButtonField has focus"

 

Why doesn't this work?

Please use plain text.
Developer
behrk2
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: Trouble invoking makeMenu() from a separate non-Screen class

I was able to get it working. My mistake was that I was trying to manipulate the focus() and unfocus() in my actual buttonfield class. By overriding the buttonfield in the class its implemented in did the trick.

 

Thanks!

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Trouble invoking makeMenu() from a separate non-Screen class

I appreciate it, but do I deserve kudos for telling you I like your idea?!

 

Anyway, glad you got it going....

Please use plain text.