Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8089385

[MacOS, Applet] Modal stages do not block input

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u20
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
    • Environment:

      MacOS 10.9.4, Firefox, applet mode

      Description

      Creating a new stage with Modality.APPLICATION_MODAL does not completely block input. It seems that InputEvents affecting the blocked stage are queued and executed after the new stage has been closed.

      The following sample demonstrates the problem:
      1. Start the application as applet
      2. Click the button "open modal stage"
      3. This opens an APPLICATION_MODAL stage
      4. Click the button "open modal stage" again
      5. Now click "Close me" on the modal stage

      -> The modal stage will close and immediatly be reopend, which is wrong.
      The second button click should have been consumed.

      This problem only happens on MacOS in AppletMode. On other platforms (Windows (including AppletMode), MacOS Desktop application) the above code works as expected.



      package com.infowerk.sample;

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Modality;
      import javafx.stage.Stage;
      import javafx.stage.StageStyle;

      public class ModalitySample extends Application {

          private Stage modalStage;
          
          @Override
          public void start(Stage primaryStage) {
              Button btn = new Button();
              btn.setText("open modal stage");
              btn.setOnAction((ActionEvent event) -> {
                  System.out.println("btnOpenModalStage clicked");
                  
                  createModalStage();
                  modalStage.showAndWait();
              });
              
              StackPane root = new StackPane();
              root.getChildren().add(btn);
              
              Scene scene = new Scene(root, 300, 250);
              
              primaryStage.setTitle("Hello World!");
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              launch(args);
          }
          
          private void createModalStage(){
              this.modalStage = new Stage();
              this.modalStage.initModality(Modality.APPLICATION_MODAL);
              this.modalStage.initStyle(StageStyle.UTILITY);
              this.modalStage.setWidth(100);
              this.modalStage.setHeight(100);
              this.modalStage.setScene(new Scene(createCloseButton()));
          }
          
          private Button createCloseButton() {
              Button btn = new Button("Close me");
              btn.setOnAction(e -> {
                  System.out.println("btnCloseModalStage clicked");
                  modalStage.close();
              });
              
              return btn;
          }
      }

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            sfuchsjfx Stefan Fuchs (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Imported: