pickOnBounds doesn't work with nodes (or at least buttons) which have a -fx-shape style specified

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P4
    • None
    • Affects Version/s: 7u25
    • Component/s: javafx
    • None
    • Environment:

      Test system was jdk8b101, win7 64bit.

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.*;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;
      // pickOnBounds + -fx-shape bug.
      public class RoundButtonClick extends Application {
        public static void main(String[] args) { launch(args); }
        @Override public void start(Stage stage) throws Exception {
          ToggleButton button = new ToggleButton("Add");
          /* set the shape of button to be circle */
          button.setStyle(
                  "-fx-font-size: 40; -fx-shape: \"m 307.14285,366.64789 c 27.7,0 50,22.3 50,50 0,27.7 -22.3,50 -50,50 -27.7,0 -50,-22.3 -50,-50 0,-27.7 22.3,-50 50,-50 z\";"
          );
          button.setMinHeight(Button.USE_PREF_SIZE);
          button.prefHeightProperty().bind(button.widthProperty());
          button.setMaxHeight(Button.USE_PREF_SIZE);
          button.setPickOnBounds(true);
      // clip based workaround.
      // Circle circularClip = new Circle();
      // circularClip.centerXProperty().bind(button.widthProperty().divide(2));
      // circularClip.centerYProperty().bind(button.heightProperty().divide(2));
      // circularClip.radiusProperty().bind(button.widthProperty().divide(2));
      // button.setClip(circularClip);
          StackPane layout = new StackPane();
          layout.getChildren().setAll(
                  button
          );
          layout.setStyle("-fx-background-color: cornsilk; -fx-padding: 20px;");
          
          stage.setScene(new Scene(layout, 180, 180));
          stage.show();
        }
      }

      To reproduce, run the attached sample, click inside the circular ToggleButton and the ToggleButton will toggle as expected.
      Click outside the ToggleButton anywhere within the enclosing rectangular bounds of the button in it's parent and the ToggleButton will still toggle, even though it is not supposed to based on it's shape and the pickOnBounds setting.

            Assignee:
            Pavel Ĺ afrata
            Reporter:
            J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: