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
Highlighted
Developer
Posts: 142
Registered: ‎12-15-2008
My Device: Not Specified
Accepted Solution

How to display a screen on top of a popupscreen?

I have a popupscreen app that when a menu item is selected a mainscreen-implemented screen will display

allowing the user to set options. However, when invoked the options screen is shown behind the popupscreen.

How do I 'hide' the popupscreen and give control to the options screen?

 

I'm calling my options screen in the following manner:

protected MenuItem _myItem = new MenuItem("Configure", 100, 10)
    {
        public void run()
        {
            UiApplication.getUiApplication().pushModalScreen( new AddItemScreen() );
        }
    };

 

Is there something wrong in this implementation?

Developer
Posts: 142
Registered: ‎12-15-2008
My Device: Not Specified

Re: How to display a screen on top of a popupscreen?

It seems that no matter what kind of screen I try to display on top of my popupscreen it always ends up behind the popup and the popup still has control. Is it even possible to display on top of a popupscreen?
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: How to display a screen on top of a popupscreen?

How are you pushing the popup? If it is global-modal, then only another global-modal screen of higher priority will display over it.

 

Developer
Posts: 142
Registered: ‎12-15-2008
My Device: Not Specified

Re: How to display a screen on top of a popupscreen?

Ok here is the basic layout of my app... It's a popupscreen app so when launched only a dialog looking screen appears. It's not a fullscreen app or
at least it doesn't appear that way to the user.

class QApp extends UiApplication implements FieldChangeListener
{
public static void main( String[] args )
{
QApp _app = new QApp();
_app.enterEventDispatcher();
}

public class MainPopupScreen extends PopupScreen {
public MainPopupScreen() {
...

{

I display my main popupscreen here in the constructor. Is this the wrong place to do it?

private QApp()
{
MainPopupScreen pScreen = new MainPopupScreen();

UiEngine ui = Ui.getUiEngine();
ui.queueStatus (pScreen, 1, true);
}

Then when I want to display my 'options' screen as a fullscreen I tried this doing this from a menu item.
I tried doing both methods here but same result..displayed behind my popup screen.

protected MenuItem _myItem = new MenuItem("Options", 100, 10)
{
public void run()
{
// pushScreen( new OptionsScreen() );
or
// UiApplication.getUiApplication().pushModalScreen( new OptionsScreen() );
}
};

So am I trying to display the options screen incorrectly or I am displaying my original popup screen incorrectly?
My options screen that I want displayed over my popup is defined as follows... It's defined as extending MainScreen.
Is this a problem?

class OptionsScreen extends MainScreen
{

OptionsScreen ()
{
super();
String title;
title = "Options" ;
setTitle( new LabelField( title, LabelField.USE_ALL_WIDTH | LabelField.ELLIPSIS ) );
}
}

I know I'm doing something fundamentally wrong so I hope someone can enlighten me.
Thanks in advance
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: How to display a screen on top of a popupscreen?

First off, you are using a deprecated API to push the screen.

 

Second, you should not push a screen from within it's constructor.

 

Something more like this woud be better:

 

Myscreen screen = new Myscreen();

pushScreen(screen);

 

(Or this might be "pushModalScreen instead)

 

Next, you should dismiss the popup once you put up another screen.

 

 

Developer
Posts: 142
Registered: ‎12-15-2008
My Device: Not Specified

Re: How to display a screen on top of a popupscreen?

I see. Thanks. That helps a lot. I'm coming from a c++ background so I'm just trying to get a hold of this thing you call 'java'. haha.

Ok. I understand. That's what I get from copying too much from a sample without doing enough research and thinking it through. I'm getting there though.
My app 'looks' good I just have to reorg it. The main hurdle I was/am having is to properly structure it so that only a dialog pops up on the screen and not
a full screen as most bb apps seem to do. So hopefully, I can get this thing working correctly.

Thanks again.
Developer
Posts: 142
Registered: ‎12-15-2008
My Device: Not Specified

Re: How to display a screen on top of a popupscreen?

So when should I push the initial popup? I see a lot of samples where a screen is pushed from a constructor but I agree this doesn't
seem like the right thing to do. Would starting a thread in the constructor and then pushing the screen be ok? Or is there a method that's automatically called after the constructor completes that I can override and push it there?
BlackBerry Development Advisor
Posts: 15,693
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: How to display a screen on top of a popupscreen?

You can push a screen from within the constructor of your application.  The recommendation was to instantiate the screen outside of the pushScreen method (create the variable first, then pass it into the pushScreen method).
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 142
Registered: ‎12-15-2008
My Device: Not Specified

Re: How to display a screen on top of a popupscreen?

Hi. I had since figured this out on my own. Thanks.