diff --git a/gemsfx/src/main/java/com/dlsc/gemsfx/PagingControlBase.java b/gemsfx/src/main/java/com/dlsc/gemsfx/PagingControlBase.java index d224394f..228f8f7e 100644 --- a/gemsfx/src/main/java/com/dlsc/gemsfx/PagingControlBase.java +++ b/gemsfx/src/main/java/com/dlsc/gemsfx/PagingControlBase.java @@ -55,13 +55,22 @@ public PagingControlBase() { setLastPageDivider(lastPageDivider); addEventFilter(KeyEvent.KEY_PRESSED, evt -> { + // important to check, otherwise this might get called / executed more than once + if (evt.isConsumed()) { + return; + } + if (Objects.equals(evt.getCode(), KeyCode.RIGHT) || Objects.equals(evt.getCode(), KeyCode.PAGE_DOWN)) { + evt.consume(); nextPage(); } else if (Objects.equals(evt.getCode(), KeyCode.LEFT) || Objects.equals(evt.getCode(), KeyCode.PAGE_UP)) { + evt.consume(); previousPage(); } else if (Objects.equals(evt.getCode(), KeyCode.HOME)) { + evt.consume(); firstPage(); } else if (Objects.equals(evt.getCode(), KeyCode.END)) { + evt.consume(); lastPage(); } }); diff --git a/gemsfx/src/main/java/com/dlsc/gemsfx/SimplePagingListView.java b/gemsfx/src/main/java/com/dlsc/gemsfx/SimplePagingListView.java index e2c83f65..5a66be36 100644 --- a/gemsfx/src/main/java/com/dlsc/gemsfx/SimplePagingListView.java +++ b/gemsfx/src/main/java/com/dlsc/gemsfx/SimplePagingListView.java @@ -23,7 +23,7 @@ public SimplePagingListView() { setLoader(lv -> { int pageSize = getPageSize(); int index = getPage() * pageSize; - return getItems().subList(index, Math.min(index + pageSize, getItems().size() - 1)); + return getItems().subList(index, Math.min(index + pageSize, getItems().size())); }); loaderProperty().addListener(it -> {