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

[ToggleButton] ToggleButton doesn't respond to space bar on Windows when the button is part of a ToggleGroup

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • 9
    • 8u40
    • javafx
    • U:\>java -version
      java version "1.8.0_40-ea"
      Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b07)
      Java HotSpot(TM) 64-Bit Server VM (build 25.40-b11, mixed mode)

    Description

      On Windows pressing the space bar initiates a 'click' action on a button that has the focus. This is not working for a ToggleButton that is assigned to a ToggleGroup (without the ToggleGroup it does work). Here is a small test program to illustrate (you can comment out the ToggleGroup section to see the space bar working on the same buttons):

      import javafx.application.Application;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.control.ToggleButton;
      import javafx.scene.control.ToggleGroup;
      import javafx.scene.layout.FlowPane;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class ToggleButtonTest extends Application {

          public static void main(String[] args) {
              launch(args);
          }
       
          @Override
          public void start(Stage stage) {
           StackPane pane = new StackPane();
           pane.getChildren().add(createContent());
           stage.setScene(new Scene(pane));
              stage.show();
      }
          
          private Node createContent() {
           FlowPane fp = new FlowPane(2, 2);
           ToggleButton tb1 = new ToggleButton("button 1");
           ToggleButton tb2 = new ToggleButton("button 2");
           ToggleButton tb3 = new ToggleButton("button 3");
           ToggleButton tb4 = new ToggleButton("button 4");
              
           // Comment out the following lines...
           ToggleGroup tg = new ToggleGroup();
           tg.getToggles().add(tb1);
           tg.getToggles().add(tb2);
           tg.getToggles().add(tb3);
           tg.getToggles().add(tb4);
           // ...to here, and the space-bar works again to select the buttons
          
           fp.getChildren().add(tb1);
           fp.getChildren().add(tb2);
           fp.getChildren().add(tb3);
           fp.getChildren().add(tb4);
           return fp;
          }
      }

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            dgilbertjfx David Gilbert (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: