summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Alhroos <john.ahlroos@itmill.com>2011-08-11 12:36:02 +0000
committerJohn Alhroos <john.ahlroos@itmill.com>2011-08-11 12:36:02 +0000
commit1f2ac63ff8976bb2de8e00605ab2e9ffa4eaf342 (patch)
tree80df61e9a7f7cb5190a1e4d16d12910fa3ab75c2 /src
parent9c670b95c2535fce7f559aa17cecdc8e61c3912b (diff)
downloadvaadin-framework-1f2ac63ff8976bb2de8e00605ab2e9ffa4eaf342.tar.gz
vaadin-framework-1f2ac63ff8976bb2de8e00605ab2e9ffa4eaf342.zip
Adds mouse wheel scrolling to VFilterSelect #4518
svn changeset:20301/svn branch:6.7
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
index 68d5e40326..108a68f73f 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
@@ -32,6 +32,7 @@ import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
@@ -175,7 +176,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
DOM.appendChild(root, down);
DOM.appendChild(root, status);
DOM.setElementProperty(status, "className", CLASSNAME + "-status");
- DOM.sinkEvents(root, Event.ONMOUSEDOWN);
+ DOM.sinkEvents(root, Event.ONMOUSEDOWN | Event.ONMOUSEWHEEL);
addCloseHandler(this);
}
@@ -318,6 +319,38 @@ public class VFilterSelect extends Composite implements Paintable, Field,
}
/*
+ * Timer for scrolling pages up or down.
+ */
+ private LazyPageScroller lazyPageScroller = new LazyPageScroller();
+ private class LazyPageScroller extends Timer {
+ private int pagesToScroll = 0;
+
+ @Override
+ public void run() {
+ if(pagesToScroll != 0){
+ filterOptions(currentPage + pagesToScroll, lastFilter);
+ pagesToScroll = 0;
+ }
+ }
+
+ public void scrollUp() {
+ if(currentPage - pagesToScroll >= 0){
+ pagesToScroll--;
+ cancel();
+ schedule(100);
+ }
+ }
+
+ public void scrollDown() {
+ if(totalMatches > (currentPage + pagesToScroll +1)*pageLength){
+ pagesToScroll++;
+ cancel();
+ schedule(100);
+ }
+ }
+ }
+
+ /*
* (non-Javadoc)
*
* @see
@@ -329,9 +362,16 @@ public class VFilterSelect extends Composite implements Paintable, Field,
if (event.getTypeInt() == Event.ONCLICK) {
final Element target = DOM.eventGetTarget(event);
if (target == up || target == DOM.getChild(up, 0)) {
- filterOptions(currentPage - 1, lastFilter);
+ lazyPageScroller.scrollUp();
} else if (target == down || target == DOM.getChild(down, 0)) {
- filterOptions(currentPage + 1, lastFilter);
+ lazyPageScroller.scrollDown();
+ }
+ } else if (event.getTypeInt() == Event.ONMOUSEWHEEL) {
+ int velocity = event.getMouseWheelVelocityY();
+ if (velocity > 0) {
+ lazyPageScroller.scrollDown();
+ } else {
+ lazyPageScroller.scrollUp();
}
}