]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes #1941: Combobox should close the dropdown menu when pressing ESC-key
authorJouni Koivuviita <jouni.koivuviita@itmill.com>
Tue, 15 Jul 2008 08:44:30 +0000 (08:44 +0000)
committerJouni Koivuviita <jouni.koivuviita@itmill.com>
Tue, 15 Jul 2008 08:44:30 +0000 (08:44 +0000)
svn changeset:5104/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java

index a23acb2ce28d16ef0c5026ca958e0caf04b71eb4..57c11c3f679d52da53e9cfaefb5de607ffa51dfb 100644 (file)
@@ -157,13 +157,9 @@ public class IFilterSelect extends Composite implements Paintable, Field,
             // We don't need to show arrows or statusbar if there is only one
             // page
             if (matches <= PAGELENTH) {
-                DOM.setStyleAttribute(status, "display", "none");
-                DOM.setStyleAttribute(up, "display", "none");
-                DOM.setStyleAttribute(down, "display", "none");
+                setPagingEnabled(false);
             } else {
-                DOM.setStyleAttribute(status, "display", "");
-                DOM.setStyleAttribute(up, "display", "");
-                DOM.setStyleAttribute(down, "display", "");
+                setPagingEnabled(true);
             }
             setPrevButtonActive(first > 1);
             setNextButtonActive(last < matches);
@@ -262,9 +258,9 @@ public class IFilterSelect extends Composite implements Paintable, Field,
                 return;
             }
             if (paging) {
-                DOM.setStyleAttribute(down, "display", "block");
-                DOM.setStyleAttribute(up, "display", "block");
-                DOM.setStyleAttribute(status, "display", "block");
+                DOM.setStyleAttribute(down, "display", "");
+                DOM.setStyleAttribute(up, "display", "");
+                DOM.setStyleAttribute(status, "display", "");
             } else {
                 DOM.setStyleAttribute(down, "display", "none");
                 DOM.setStyleAttribute(up, "display", "none");
@@ -704,6 +700,20 @@ public class IFilterSelect extends Composite implements Paintable, Field,
                     tb.selectAll();
                     break;
                 }
+            case KeyboardListener.KEY_ESCAPE:
+                if (currentSuggestion != null) {
+                    String text = currentSuggestion.getReplacementString();
+                    tb.setText((text.equals("") ? emptyText : text));
+                    // TODO add/remove class CLASSNAME_EMPTY
+                    selectedOptionKey = currentSuggestion.key;
+                } else {
+                    tb.setText(emptyText);
+                    // TODO add class CLASSNAME_EMPTY
+                    selectedOptionKey = null;
+                }
+                lastFilter = "";
+                suggestionPopup.hide();
+                break;
             default:
                 filterOptions(currentPage);
                 break;