summaryrefslogtreecommitdiffstats
path: root/compatibility-server
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2020-05-19 13:13:25 +0300
committerGitHub <noreply@github.com>2020-05-19 13:13:25 +0300
commit0645a86e5b6951de0e5b170657a2eaf74a7e9b77 (patch)
tree9c327c0e4f21a129a8815ae796196aaf5ff3ce51 /compatibility-server
parent667da64f804528a3e4a93dda3db708085104b844 (diff)
downloadvaadin-framework-0645a86e5b6951de0e5b170657a2eaf74a7e9b77.tar.gz
vaadin-framework-0645a86e5b6951de0e5b170657a2eaf74a7e9b77.zip
Table / TreeTable multiselect disabling of touch detection (#12014)
Added a toggle in Table (and thus TreeTable) where you can explicitly disable multiselect touch screen detection. This allows you to work around issues on hybrid devices that have both a touch screen and a keyboard where you don't want automatic simple multiselection applied. Fixes #11601, slightly modified cherry-pick of #11641
Diffstat (limited to 'compatibility-server')
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java36
1 files changed, 35 insertions, 1 deletions
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java
index 433254aa67..0519e20f75 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java
@@ -588,6 +588,8 @@ public class Table extends AbstractSelect implements Action.Container,
private MultiSelectMode multiSelectMode = MultiSelectMode.DEFAULT;
+ private boolean multiSelectTouchDetectionEnabled = true;
+
private boolean rowCacheInvalidated;
private RowGenerator rowGenerator = null;
@@ -3775,6 +3777,10 @@ public class Table extends AbstractSelect implements Action.Container,
if (isSelectable()) {
target.addAttribute("selectmode",
(isMultiSelect() ? "multi" : "single"));
+ if (isMultiSelect()) {
+ target.addAttribute("touchdetection",
+ isMultiSelectTouchDetectionEnabled());
+ }
} else {
target.addAttribute("selectmode", "none");
}
@@ -5188,7 +5194,10 @@ public class Table extends AbstractSelect implements Action.Container,
* <p>
* Note, that on some clients the mode may not be respected. E.g. on touch
* based devices CTRL/SHIFT base selection method is invalid, so touch based
- * browsers always use the {@link MultiSelectMode#SIMPLE}.
+ * browsers always use the {@link MultiSelectMode#SIMPLE} unless touch multi
+ * select is explicitly disabled.
+ *
+ * @see #setMultiSelectTouchDetectionEnabled(boolean)
*
* @param mode
* The select mode of the table
@@ -5208,6 +5217,31 @@ public class Table extends AbstractSelect implements Action.Container,
}
/**
+ * Default behavior on touch-reporting devices is to switch from CTRL/SHIFT
+ * based multi-selection to simple mode, but you can use this method to
+ * explicitly disable the touch device detection. Thus you can keep using
+ * keyboard-based multi selection on hybrid devices that have both a touch
+ * screen and a keyboard.
+ *
+ * @param multiSelectTouchDetectionEnabled
+ * Whether to enable or disable touch screen detection
+ */
+ public void setMultiSelectTouchDetectionEnabled(
+ boolean multiSelectTouchDetectionEnabled) {
+ this.multiSelectTouchDetectionEnabled = multiSelectTouchDetectionEnabled;
+ markAsDirty();
+ }
+
+ /**
+ * Returns if touch screen detection is used to toggle multi select mode.
+ *
+ * @return If touch screen detection for multi select is enabled
+ */
+ public boolean isMultiSelectTouchDetectionEnabled() {
+ return multiSelectTouchDetectionEnabled;
+ }
+
+ /**
* Lazy loading accept criterion for Table. Accepted target rows are loaded
* from server once per drag and drop operation. Developer must override one
* method that decides on which rows the currently dragged data can be