PopupScreen to dismiss

Hi all

I created PopupScreen on the main screen, but now I would like to reject the popupscreen by the ESC key.

How would I do that?

Thanks in advance.

DK.

PopupScreen extends the screen has a keyChar method, which is what I normally override to provide this feature.

So basically all you need to do is add a keyChar method as follows to your PopupScreen.  (Note the following code has not been compiled or tested, but should show you what you need to do).

protected boolean keyChar(char c, int status, int time) {
    if ( key ==  Characters.ESCAPE ) {
        UiApplication.getUiApplication().popScreen(this);
        return true;
    }
    return super.keyChar(key,status,time);
}

Tags: BlackBerry Developers

Similar Questions

  • Dismiss the iOS 10 Timer

    Does anyone know of a way to change the style of the iPad in iOS 10 timer notifications? In earlier versions, a timer at the end of the notification was similar to an alert HTML he had an OK button visible on the background. This allowed quick reference of the notification and, especially, to silence the alarm.

    In iOS 10, the notification style that I see has changed. It is now a close notification (height) with no OK button visible. I have to slide down on a gray bar very close to expand the notification and get to the OK button. Not only the Act to expand the notification process takes more time, but the fact that the gray bar seems to require a precise contact to accomplish the clamp which means a dismissal which previously took less than a second now takes five or seconds while I try frantically to extend the notification to the OK button.

    I searched through notifications, hoping I could change something of the style, but there is nothing here of clock, alarm, timer, etc. A research in "timer" parameters, "the clock", results etc. in no topics found.

    Try to swipe through the Notification to open it.

  • From a few days ago, I can't dismiss reminders of calendar for my Google calendar in lightning.

    My Google calendar in lightning now has an exclamation mark next to it. I have looked in the error console and see a lot of errors about events in the calendar, but don't know enough to interpret. If a reminder for an event that I can either dismiss or snooze it. I can only close its window. I tried to remove the calendar and put it back, but that made no difference.

    How is it that is related to the Firefox support?

    https://support.Mozilla.org/en-us/KB/using-lightning-Google-Calendar

  • Set the position of a PopupScreen

    Is there a way to define the position of top, on the left of a PopupScreen? SetPosition(x,y) call will throw this error:

    java.lang.IllegalStateException: setPosition called outside the layout

    I use JDE 4.2.1 8800 Simulator.

    Thank you

    Ryan

    Quote from the old forum:

    ligraseac

    Messages: 2
    Join date: Jun 2007

    Screen Popup position
    Posted the: June 29, 2007 05:45
     
    Hello

    How can I set the position of a popup screen? I want to set its position next to a field that has the focus.

    Thank you

    Comments: fjarlier
    Re: Screen Popup Position
    Posted the: 5 July 2007 17:10
     
    Hello

    In your class that extends the PopupScreen, you must override sublayout like this:

    ' public void sublayout (int width, int height) {}

    Super.sublayout (Width, Height);
    setPosition (50,50);
    }

    Because the setPosition can occurs only in the layout method. And then, you can position your PopupScreen anywhere you want.

    For me it works...

    If you have another solution, that I take.

    So long

    Fred

  • Programmatically dismiss blackberry.ui.toast?

    I have a launched a toast with a long delay while a background operation finishes, but I can't find a way to programmatically dismiss the toast when the other task is complete. Is it possible to use the toastId for this?

    Hello

    Short answer is no. A Toast is an alert dialog box. What you should probably use is an indicator of activity or some sort.

    Do you use a framework for your application? Chances are that an activity spinner option is available.

  • Problem with PopupScreen.updateLayout)

    Hello guys '

    I have a problem with PopupScreen. I'm doing the cursor on the PopupScreen. This popupScreen includes BitmapField with transparent image. And the main screen is BitmapField larger than the size of the screen. I want to move the cursor (PopupScreen) on the BitmapField.

    You see what I'm doing here. And I found the solution how to move PopupScreen since the last post. Now, I am facing the problem when the cursor (PopupScreen) on the left. In other words, when I move the slider to the left, it is not clear previous position. I don't know why.

    It works fine when moves right.

    And it is not clear the previous, when position moves to the left.

    So, you can see the code that I use.

    import net.rim.device.api.ui.component.*;import net.rim.device.api.ui.container.*;import net.rim.device.api.ui.*;import net.rim.device.api.system.Bitmap;import net.rim.device.api.system.KeyListener;
    
    public class CursorField extends UiApplication {
    
      private InfoPopupScreen progressPopup;    int x = 180;  int y = 120;  ManagedScreen managedScreen;  Bitmap _bitmap1;  Bitmap _bitmap2;  Bitmap _bitmap;   int [] fillTrans = new int[100];
    
      public CursorField() {
    
          _bitmap = Bitmap.getBitmapResource("cursor1.png");        _bitmap1 = Bitmap.getBitmapResource("cursor1.png");       _bitmap2 = Bitmap.getBitmapResource("cursor2.png");
    
          for(int i = 0; i < 100; i++) {         fillTrans[i] = 0xFFFFFF;      }
    
          managedScreen = new ManagedScreen();      pushScreen(managedScreen);    }
    
      private class InfoPopupScreen extends PopupScreen implements KeyListener {
    
          protected void applyTheme() {         //Nothing     }
    
          public boolean keyStatus(int keycode, int time) {         return false;     }
    
          public boolean keyRepeat(int keycode, int time) {         return false;     }
    
          public boolean keyUp(int keycode, int time) {         return false;     }
    
          public InfoPopupScreen(Manager manager){          super(manager);       }
    
          protected boolean navigationMovement(int dx, int dy, int status, int time) {
    
              return true;      }
    
          protected void paintBackground(Graphics graphics) {           graphics.setBackgroundColor(16777215);        }
    
          public void sublayout(int width, int height){         super.sublayout(width, height);           setPosition(x, y);        }
    
          public boolean keyDown(int keycode, int time) {
    
              char key =  net.rim.device.api.ui.KeypadUtil.getKeyChar(keycode, net.rim.device.api.ui.KeypadUtil.MODE_UI_CURRENT_LOCALE);            //To left         if(key == 79 || key == 111) {             x = x - 5;                progressPopup.updateLayout();         }                      if(key == 73 || key == 105) {             x = x + 10;               progressPopup.updateLayout();         }
    
              if(key == net.rim.device.api.system.Characters.ESCAPE) {              this.close();         }         return true;      }
    
          public boolean keyChar(char key, int status, int time) {          return false;     }
    
          public boolean trackwheelRoll(int amount, int status, int time) {         return false;     }
    
          public boolean trackwheelUnclick( int status, int time ) {            return false;     }
    
          public boolean trackwheelClick( int status, int time ) {          super.trackwheelClick(status, time);          return true;      } }
    
      private class ManagedScreen extends MainScreen {      private BitmapField _cursorField;
    
          public ManagedScreen() {
    
              _cursorField = new BitmapField(_bitmap) {             public void paint(Graphics graphics) {                    graphics.setBackgroundColor(16777215);                    super.paint(graphics);                }         };
    
              FlowFieldManager manager = new FlowFieldManager(FlowFieldManager.USE_ALL_HEIGHT | FlowFieldManager.USE_ALL_WIDTH) {               public void paint(Graphics graphics) {                    graphics.setBackgroundColor(16777215);                    super.paint(graphics);                }         };
    
              manager.add(_cursorField);            progressPopup = new InfoPopupScreen(manager);
    
              Bitmap pic = Bitmap.getBitmapResource("background.jpg");          BitmapField picField = new BitmapField(pic);          add(picField);
    
              ButtonField _closeButton = new ButtonField("Push screen", ButtonField.CONSUME_CLICK | ButtonField.FIELD_HCENTER);         _closeButton.setChangeListener(new FieldChangeListener() {                public void fieldChanged(Field field, int context) {                  pushScreen(progressPopup);                }         });
    
              add(_closeButton);        } }
    
      public static void main(String[] args) {      CursorField application = new CursorField();      application.enterEventDispatcher();   }}
    

    I hope you can solve my problem.

    TNX in advance"

    Ttry this...   In paintBackground(), call clear after you set the background color.

  • How to remove the global popupscreen?

    Hello everyone,

    I create the application such that when the application starts at the beginning so I put this request

    in the background and then I push the global popupscreen for help

    UiApplication.getUiApplication () .pushGlobalScreen (currentpopupScreen, 1, UiApplication.GLOBAL_MODAL);

    afterwords when I want to delete this global else popupscreen class, I used the following line of code

    UiApplication.getUiApplication () .popScreen (UiApplication.getUiApplication () .getActiveScreen ());

    but this gives the exception because UiApplication.getUiApplication () .getActiveScreen () returns null.

    So how to remove this global popupscreen? because the other class getActiveScreen () method returns null.

    Thanks in advance

    If I push two (or more) screens with the same priority, newest pushed overall appears on top. I tested.

    Thank you for your suggestion.

  • Quick question PopupScreen VerticalFieldManager:

    I'm building a contextual menu screen custom that displays two text fields, an OK and CANCEL button.  I use the VerticalFieldManager as the Manager.  I used the styles Field.FIELD_RIGHT and Field.FIELD_LEFT for the OK and CANCEL buttons to the OK button on the left side of the dialog box (under the text fields) and the button CANCEL on the right side.

    The only problem I have with the screen, it is that, since I'm on the VerticalFieldManager, the OK and CANCEL button are on different lines.  Is there a style of field that will put them on the same line, even if I use the VerticalFieldManager?  Or should I use a different Manager.

    Thanks in advance...

    mlisaoverdrive wrote:

    johnbibs wrote:

    Hi mlisaoverdrive,

    By defalt, popupscreen uses the vertical area manager, so that you can do is put two buttons in a HorizontalFieldManager. Then add the Manager of horizontalfield on the screen.

    Wait I'm confused... According to the docs, you must provide a handler delegate for PopupScreen.  Does not mean that it is not a default Manager?

    Sorry my bad, I was talking about the screen. in any case, just use the VerticalFieldManager as your cost of Manager. Then put your buttonFields in a single horizontal FieldManager. then after the addition of some fields in your form, add the horizontalfieldmanager in the last.

  • UiApplication using PopupScreen

    Hi all

    This is my first post on this amazing forum. I read through many large threads with lots of answers to the questions I had in my short time developing applications for the BlackBerry smartphone. Unfortunately, I hit my first stumbling block, which I'm sure will be very easy, but hey, we all start somewhere.

    The question that I'm doing the experience simply creates a PopupScreen in the mainevent thread and wait for user input before continuing. In my days of Swing I just use an observable model and notify the application of change, but I seem to have trouble with this concept here. I tried to use the pushModalScreen and the pushGlobalScreen of the UiApplication class methods, but both give me a runtime... error pushGlobalScreen called by thread of non-event.

    It seems to me missing something probably just in front of me, but I would appreciate help on this. I just use this example using the 9000 Simulator that is packed with the JDE v4.6

    public static void main(String[] args) {
            MyApp app = new MyApp();
            app.enterEventDispatcher();
        }
    
        MyApp() {
            final PromptTest prompt = new PromptTest();
            invokeLater(new Runnable() {
                public void run() {
                    pushGlobalScreen(prompt,1,UiApplication.GLOBAL_MODAL);
                }
            });
            continueProcess();
        }
    
        public void continueProcess() {
        // do something with input from PopupScreen
        }
    }
    

    Thank you.

    Well, I'm a little bit embarrassed. I have solved my problem. Using just pushScreen, like any other approach and all simply migrate code to deal with in my fieldChangeListener. I don't know what I thought earlier. I'm sorry to have lost someone's time on this one.

  • Cannot close the PopupScreen

    I have a PopupScreen, NHCustomPopupScreen.

    When a function is called, I display this screen:

    NGCustomPopupScreen ngcps = new NGCustomPopupScreen();
    UiApplication.getUiApplication () .pushScreen (ngcps);

    After the function finishes its work, I want to close the NGCustomPopupScreen.  I'm sure that this is my problem, but I'm not sure what to change here.

    UiApplication.getUiApplication () .popScreen (UiApplication.getUiApplication () .getActiveScreen ());

    The NGCustomPopupScreen does not close.  Everything continues to operate.  Looks like I'm missing something small on this one.

    Hey Champ,.

    the problem could be that the other screen is active at the moment.

    You can try adding the next checkig as:

    Screen = UiApplication.getUiApplication () .getActiveScreen ();

    If (NHCustomPopupScreen instanceof screen)
    {
    UiApplication.getUiApplication () .popScreen (screen);
    }

    Also if you have the screen reference I would more simple:

    NGCustomPopupScreen ngcps = new NGCustomPopupScreen();

    .....

    UiApplication.getUiApplication () .popScreen (ngcps);

    And also please wrap all the UI code inside the following construction (you will find more in the UI Developer's guide):

    Synchronize (UiApplication.getUiApplication (.getEventLock))

    {}

  • Problem with dismissing the dialog box

    Hello world

    This is my first post here. Sorry if the question is very simple...

    I need to download an image on server. I display a dialog box to confirm if the file should be downloaded.

    Everything works well except that the dialog box is dismissed after that the whole process is over. I know I'm missing something-related threads. pls help me to understand.

    Here is my code:

    public void fieldChanged(Field f, int context) {
        if (f == addButton) {
                        FileSelectorPopupScreen fps = new   FileSelectorPopupScreen();
            fps.pickFile();
            theFile = fps.getFile();
    
            if (theFile == null) {
                Dialog.alert("Screen was dismissed.  No file was selected.");
            }
            else {
                UiApplication.getUiApplication().invokeAndWait (new  Runnable(){
                public void run(){
                    int confirmationResult = Dialog.ask(Dialog.D_YES_NO, "Do you                    want to upload?", Dialog.YES);
                    if (confirmationResult==Dialog.YES) {
                             status=1;
                    } else {
                             status=0;
                    }
                }
              });
    
            }
    
            if(status==1){
                Thread t= new Thread(){
                    public void run(){
                        //MY CALL TO WEBSERVICE                     }
                }};
    
                try{
                    t.start();
                    t.join();                                           refreshData(); //call to method to post the image data to server                        //and refresh the screen with new image
                }
                catch(Exception e){
    
                }
    
                }
            }
    
        }
    

    My problem is that the I selected YES the dialog box only after the call to webservice licensees are completed and the image is published on the server and the screen is refreshed with the new image.

    Let me know what I'm missing.

    Welcome to the forum!

    Correctly, you start the process of network on a separate Thread.  Then you attach the wire event for this Thread by using the following instructions:

    t.Start ();
    t.Join ();

    So you give up the thread of events not until your networking activity has finished.  It does not block your event feed so that your application will become unresponsive to the user and as you noted, activities requiring feed event, such as the removal of your dialog box, cannot occur.

    You must reprogram your treatment so that the activity of the network as a completely asynchronous operation.  You can't wait on this.  You should get to tell you when it has finished.  I suggest that looking at the observer model during the implementation of this process.

  • How to start a PopupScreen?

    Hello

    I am facing a strange problem with PopupScreen and how to throw one.

    I try to make a page "load" that is displayed during the execution of a thread.

    I started with a sample code here: http://supportforums.blackberry.com/t5/Java-Development/Sample-Please-Wait-or-Progress-Bar-Code/td-p...

    That's why the way I call the PopupScreen can be weird.

    My problem is that when I want to launch the anti-pop in the constructor of the screen, I have a RuntimeException and when I put it in a ButtonField change event and simulate the click event it works fine.

    So I was wondering what is the difference?

    For your information, this is my code that works:

    public final class ScreenCache extends MainScreen
    {
        Screen s;
        PleaseWaitPopupScreen waitScreen = null;
    
        public ScreenCache()
        {
            super(NO_VERTICAL_SCROLL | USE_ALL_WIDTH);
            s = this;
    
            ButtonField startButton = new ButtonField("Start", ButtonField.LEFT | ButtonField.CONSUME_CLICK);
            startButton.setChangeListener( new FieldChangeListener()
            {
                public void fieldChanged(Field field, int context)
                {
                    waitScreen = new PleaseWaitPopupScreen("Chargement", "Chargement des données");
    
                    ThreadCache _requestThread = new ThreadCache(waitScreen);
                    _requestThread.start();
    
                    UiApplication.getUiApplication().pushModalScreen(waitScreen);
    
                    UiApplication.getUiApplication().popScreen(s);
                    UiApplication.getUiApplication().pushScreen(new ScreenList());
                }
            });
            this.add(startButton);
    
            EventInjector.invokeEvent(new EventInjector.NavigationEvent(EventInjector.NavigationEvent.NAVIGATION_CLICK, 0, 0, 0));
            EventInjector.invokeEvent(new EventInjector.NavigationEvent(EventInjector.NavigationEvent.NAVIGATION_UNCLICK, 0, 0, 0));
        }
    
       protected void paint(Graphics graphics)
        {
            EncodedImage ei = EncodedImage.getEncodedImageResource("img/SplashScreen.png");
            EncodedImage ei2 = new ToolsImage().ResizeImage(ei, Display.getWidth(), 0);
    
            graphics.drawBitmap(new XYRect(0, 0, Display.getWidth(), Display.getHeight()), ei2.getBitmap(), 0, 0);
        }
    
       protected boolean onSavePrompt()
       {
           return true;
       }
    
    }
    

    My PopupScreen is very simple, it only shows text and animated images, so the problem probably isn't there.

    I'm on version 5.0 and I'm on the BlackBerry 9550 Simulator tetsing.

    Try using invokeLater pushModal, anti-pop and pushScreen calls.

    Scott

  • Menu remains visible after you make the selection, and does not show Popupscreen

    Hey. Unable to get a (a gaugefield) on a Popupscreen progress bar to show. It is called from a menu. The user clicks a menu item, and a method is called. The method among other pushes a Popupscreen containing a Gaugefield on display battery-code below. Then, he starts a thread which downloads an image and using join() to wait for it complete (long story). Then, in the thread of events, it appears the Popupscreen.

    The menu does not disappear when you click on it in the Simulator (JDE 4.7, the Bold 9700 sim), but the download happens. Once the download is complete, the menu disappears, the Popupscreen is shown and he tried to pop() Popupscreen, causing an IllegalArgumentException.

    I tried to split the method into two methods, the download happened in the 2nd method, because I read the forum search that the UIEngine don't update the display until the method finishes (it runs in the event thread). But it made no difference...

    How can I get this menu to disappear immediately and the push (popup) to work?

    See you soon!

    Justin.

                            progressbar = new GaugeField("", 0, 100, 50, GaugeField.NO_TEXT);
                            progress = new PopupScreen(new FlowFieldManager()) { protected void OnDisplay() { super.onDisplay(); /*cancelButton.setFocus();*/  }  };
                            globalTiles.pushScreen(progress);
    
                            progress.add(new LabelField("Downloading (rest of) picture ..."));
                            progress.add(progressbar);
                            progress.setFocus();
    
                            if (!threadbg.isAlive()) {
                                       threadbg = new ThreadForBgDownload();
                                       threadbg.start();
                            }
                            else {
                                       // Show the progress bar, mostly complete (it is running and was in the bg). Game will start after last bit done
                            }
    
                            threadbg.join(); // Wait for download thread to complete and 'die'
    
                            globalTiles.popScreen(progress);
    

    Rule #1: all display updates should occur on the thread event or synchronized on the lock of the event.

    Rule #2: the thread of events (or now the lock of the event) should never be blocked by lengthy operations.

    The scenario you sketched out is usually handled like this: menu item run() method don't whatever immediate user interface updates are necessary and starts a worker thread. It does not wait until the thread ends before returning. (If so, updates the user interface include pushing a "Please wait" or progress pop up). The worker, at the same time, begins to do its stuff. When it's time to update the user interface (either because the task is completed or to view progress) the worker thread usually called invokeLater (Runnable) (a method in the Application class) where the executable run() method updates the user interface. If the worker thread must receive user input in his work, he can use invokeAndWait (Runnable), where the executable not all interactions of the user and stores the user entry somewhere so that the worker thread can grab after invokeAndWait() returns.

    Although the synchronization on event lock works perfectly well, it is more common for some reason any to invoke a Runnable, perhaps because the latter clearly encapsulates in a separate object the work to be done on the event thread.

    The above policy is the basis of the excellent Peter Strange example I linked to before.

  • View PopupScreen on TouchEvent.DOWN - who is TouchEvent.UP?

    I am writing this post so much hope to get a response and, in the case I find myself, to post the answer with my findings.

    Here's the situation:

    I display (pushScreen invokeLater inside) a small PopupScreen (a bubble) when a user touches a field containing the ToolTip (title text, in HTML terminology) defined.

    When the user deletes the finger, I want the balloon go (anti-pop or close() the popup itself).  However, I can't know what screen - the screen below or above the PopupScreen - Gets the TouchEvent.UP in this situation.  Debugger does not help as much as it disrupts the sequence of key events.

    If someone has done something similar, please answer.

    Found the answer - person don't be TouchEvent.UP!  Thanks to a screen pushed the screen gets TouchEvent.CANCEL immediately, as soon as the balloon is visible.  Use the information as you see fit.

  • popupscreen extention problem

    Hello everyone.

    I am trying to open a java popupscreen of an extention and shows me the following error message, telling me that I am doing wrong or if it is an example.

    java.lang.IllegalStateException: interface engine user accessed without holding the lock on the event.

    package samplecode;
    
    import net.rim.device.api.script.ScriptableFunction;
    import net.rim.device.api.system.Alert;
    import net.rim.device.api.ui.UiApplication;
    
    public final class AlertFunction extends ScriptableFunction {
    
        public Object invoke(Object obj, Object[] args) throws Exception {
           if (!Alert.isVibrateSupported()) {
              return UNDEFINED;
           }
           if (args.length == 1) {
              int duration = ((Integer)args[0]).intValue();
              Alert.startVibrate(duration);
              box vbox = new box();
                UiApplication.getUiApplication().pushScreen(vbox);
                //UiApplication.getUiApplication().popScreen(vbox);
           }
           return UNDEFINED;
        }
    }
    
    package samplecode;
    
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.PopupScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class box extends PopupScreen {
    
        /**
         *
         */
        public box() {
            super(new VerticalFieldManager());
            LabelField labelField = new LabelField("Popup Screen",
                    Field.FIELD_HCENTER);
            add(labelField);
            ButtonField btnfldOk = new ButtonField("OK", ButtonField.CONSUME_CLICK
                    | Field.FIELD_HCENTER);
            btnfldOk.setMinimalWidth(100);
            add(btnfldOk);
            ButtonField btnfldCancel = new ButtonField("Cancel",
                    ButtonField.CONSUME_CLICK | Field.FIELD_HCENTER);
            add(btnfldCancel);
            // TODO Auto-generated constructor stub
        }
    
    }
    

    Hi chicoxml,

    This line is your problem:

    UiApplication.getUiApplication () .pushScreen (vbox);

    The problem and the solution is very well described in this thread. Check it out and let me know if it solved for you:

    http://supportforums.BlackBerry.com/T5/Java-development/updating-UI-from-system-thread-UI-engine-ACC...

Maybe you are looking for