From f142bee22fcf7b7c7c3ee36465a5affe1ba9d67b Mon Sep 17 00:00:00 2001 From: Thorben Groos Date: Wed, 3 Jun 2020 20:57:45 +0200 Subject: [PATCH] Tables are treated a bit different to Texts and StyledTexts ... because they consume the mouse event, event if there is no SWT.V_SCROLL, SWT-H_SCROLL or SWT.READ_ONLY. --- .../jcryptool/core/util/ui/auto/SmoothScroller.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/org.jcryptool.core.util/src/org/jcryptool/core/util/ui/auto/SmoothScroller.java b/org.jcryptool.core.util/src/org/jcryptool/core/util/ui/auto/SmoothScroller.java index 10e4bcf182..a43700b7e6 100644 --- a/org.jcryptool.core.util/src/org/jcryptool/core/util/ui/auto/SmoothScroller.java +++ b/org.jcryptool.core.util/src/org/jcryptool/core/util/ui/auto/SmoothScroller.java @@ -2,11 +2,14 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseWheelListener; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Scrollable; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.Text; /** * This class is an (hopefully) easy to use class to @@ -66,12 +69,16 @@ public static void scrollSmooth(ScrolledComposite sc) { */ private void addTo(Control control) { for (Control child : ((Composite) control).getChildren()) { - // Add the mouseWheelListener to all controls that are able to scroll. - if (child instanceof Scrollable) { + // Add the mouseWheelListener to Texts, StyledTexts and Tabels. They are the most common + // controls that consume mouse events instead of forwarding them. + if (child instanceof Text || child instanceof StyledText || child instanceof Table) { // Scrollable controls with one of the following SWT-tags prevent // a scolledComposite from being scrolled, if the user // scrolls on its mouse wheel. - if (ScrollingUtils.controlHasFlag(child, new int[] {SWT.V_SCROLL, SWT.H_SCROLL, SWT.READ_ONLY})) { + // Tables do not need to have on of the flags set. They consume the + // scroll event at every time instead of redirecting it to a control+ + // that can be scrolled. + if (child instanceof Table || ScrollingUtils.controlHasFlag(child, new int[] {SWT.V_SCROLL, SWT.H_SCROLL, SWT.READ_ONLY})) { child.addMouseWheelListener(new MouseWheelListener() { @Override