Skip to content

Commit

Permalink
8272118: ListViewSkin et al: must not cancel edit on scrolling
Browse files Browse the repository at this point in the history
Reviewed-by: aghaisas, kcr
  • Loading branch information
Jeanette Winzenburg committed Dec 2, 2021
1 parent 5bd72a7 commit aa045c5
Show file tree
Hide file tree
Showing 6 changed files with 566 additions and 28 deletions.
Expand Up @@ -217,13 +217,6 @@ public ListViewSkin(final ListView<T> control) {
getChildren().add(flow);

EventHandler<MouseEvent> ml = event -> {
// RT-15127: cancel editing on scroll. This is a bit extreme
// (we are cancelling editing on touching the scrollbars).
// This can be improved at a later date.
if (control.getEditingIndex() > -1) {
control.edit(-1);
}

// This ensures that the list maintains the focus, even when the vbar
// and hbar controls inside the flow are clicked. Without this, the
// focus border will not be shown when the user interacts with the
Expand Down
Expand Up @@ -98,13 +98,6 @@ public TableViewSkin(final TableView<T> control) {
flow.setCellFactory(flow -> createCell());

EventHandler<MouseEvent> ml = event -> {
// RT-15127: cancel editing on scroll. This is a bit extreme
// (we are cancelling editing on touching the scrollbars).
// This can be improved at a later date.
if (control.getEditingCell() != null) {
control.edit(-1, null);
}

// This ensures that the table maintains the focus, even when the vbar
// and hbar controls inside the flow are clicked. Without this, the
// focus border will not be shown when the user interacts with the
Expand Down
Expand Up @@ -144,13 +144,6 @@ public TreeTableViewSkin(final TreeTableView<T> control) {
setRoot(getSkinnable().getRoot());

EventHandler<MouseEvent> ml = event -> {
// RT-15127: cancel editing on scroll. This is a bit extreme
// (we are cancelling editing on touching the scrollbars).
// This can be improved at a later date.
if (control.getEditingCell() != null) {
control.edit(-1, null);
}

// This ensures that the table maintains the focus, even when the vbar
// and hbar controls inside the flow are clicked. Without this, the
// focus border will not be shown when the user interacts with the
Expand Down
Expand Up @@ -166,13 +166,6 @@ public TreeViewSkin(final TreeView control) {
setRoot(getSkinnable().getRoot());

EventHandler<MouseEvent> ml = event -> {
// RT-15127: cancel editing on scroll. This is a bit extreme
// (we are cancelling editing on touching the scrollbars).
// This can be improved at a later date.
if (control.getEditingItem() != null) {
control.edit(null);
}

// This ensures that the tree maintains the focus, even when the vbar
// and hbar controls inside the flow are clicked. Without this, the
// focus border will not be shown when the user interacts with the
Expand Down
Expand Up @@ -24,11 +24,14 @@
*/
package javafx.scene.control.skin;

import java.util.List;

import com.sun.javafx.scene.control.VirtualScrollBar;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.control.IndexedCell;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.Skin;
import javafx.scene.layout.StackPane;

public class VirtualFlowShim<T extends IndexedCell> extends VirtualFlow<T> {
Expand Down Expand Up @@ -110,6 +113,36 @@ public void addLeadingCells(int currentIndex, double startOffset) {

//------------------- statics --------------------

/**
* Returns the VirtualFlow managed by the given skin.
*/
public static <T extends IndexedCell<?>> VirtualFlow<T> getVirtualFlow(Skin<?> skin) {
return ((VirtualContainerBase<?, T>) skin).getVirtualFlow();
}

/**
* Returns the list of cells displayed in the viewport of the flow.
*
* @see VirtualFlow#getCells()
*/
public static <T extends IndexedCell<?>> List<T> getCells(VirtualFlow<T> flow) {
return flow.getCells();
}

/**
* Returns the vertical scrollbar of the given flow.
*/
public static ScrollBar getVBar(VirtualFlow<?> flow) {
return flow.getVbar();
}

/**
* Returns the horizontal scrollbar of the given flow.
*/
public static ScrollBar getHBar(VirtualFlow<?> flow) {
return flow.getHbar();
}

public static <T> T cells_getFirst(VirtualFlow.ArrayLinkedList<T> list) {
return list.getFirst();
}
Expand Down

1 comment on commit aa045c5

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.