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

ScrollEvent not fired in ListView, TableView, ScrollPane etc.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 8u25
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Environment:

      Windows 7 Enterprise 64-bit, JDK1.8-25

      Description

      When I register a handler for a ListView by calling listView.setOnScroll(...), my handler would never be called with the exception of scrolling by mouse wheel beyond the scroll limits.

      My thought of setOnScroll is, that the handler get called when the user scrolls the content by ScrollBar, mouse wheel (or gesture) and also by keyboard. Please correct me if I misunderstood the method signature.

      Here is a code snippet to test the (in my opinion) wrong behavior. I think the "mistake" happens in VirtualFlow by consuming ScrollEvent.

      {code:title=SimpleScrollApp.java|borderStyle=solid}
      package simplescrolltest;

      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Scene;
      import javafx.scene.control.ListView;
      import javafx.scene.input.ScrollEvent;
      import javafx.scene.layout.AnchorPane;
      import javafx.stage.Stage;

      public class SimpleScrollApp extends Application {
          private final ObservableList<String> data = FXCollections.observableArrayList();
          
          @Override
          public void start(Stage primaryStage) {
              
              for (int i = 0; i < 100; i++) {
                  data.add(String.format("ScrollMe " + i));
              }

              ListView listView = new ListView();
              listView.setItems(data);
              
              listView.setOnScroll((ScrollEvent event) -> {
                  // This event handler is called only if we scroll by mouse wheel beyond the limits.
                  // No scrolling from ScrollBar nor KeyBoard (PageUp/Down) is handled.
                  System.out.println("ListView.onScroll handler called: " + event);
              });
              
              AnchorPane root = new AnchorPane();
              root.getChildren().add(listView);
              AnchorPane.setTopAnchor(listView, 0.0);
              AnchorPane.setBottomAnchor(listView, 0.0);
              AnchorPane.setLeftAnchor(listView, 0.0);
              AnchorPane.setRightAnchor(listView, 0.0);
              
              Scene scene = new Scene(root, 300, 250);
              
              primaryStage.setTitle("Hello World!");
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }
      }
      {code}

        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: