aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2009-10-05 12:22:46 +0000
committerHenri Sara <henri.sara@itmill.com>2009-10-05 12:22:46 +0000
commiteb827ea41e59e2021595efdc239a251aef05cfa6 (patch)
treebac938b9381c21f8fe5bd8e026cdd87ef9aa1c61
parent72429736459f2454e8e3ef78bbe808f44b50131f (diff)
downloadvaadin-framework-eb827ea41e59e2021595efdc239a251aef05cfa6.tar.gz
vaadin-framework-eb827ea41e59e2021595efdc239a251aef05cfa6.zip
#3027 Combobox left in wrong state when typing quickly
svn changeset:9078/svn branch:6.1
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java50
1 files changed, 39 insertions, 11 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
index 5b834f9f4d..ac042eb899 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
@@ -47,7 +47,7 @@ import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VTooltip;
/**
- *
+ *
* TODO needs major refactoring (to be extensible etc)
*/
public class VFilterSelect extends Composite implements Paintable, Field,
@@ -286,7 +286,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.user.client.ui.PopupPanel$PositionCallback#setPosition
* (int, int)
@@ -460,6 +460,19 @@ public class VFilterSelect extends Composite implements Paintable, Field,
suggestionPopup.hide();
return;
}
+
+ selecting = filtering;
+ if (!filtering) {
+ doPostFilterSelectedItemAction();
+ }
+ }
+
+ public void doPostFilterSelectedItemAction() {
+ final MenuItem item = getSelectedItem();
+ final String enteredItemValue = tb.getText();
+
+ selecting = false;
+
// check for exact match in menu
int p = getItems().size();
if (p > 0) {
@@ -567,6 +580,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
private String selectedOptionKey;
private boolean filtering = false;
+ private boolean selecting = false;
private String lastFilter = "";
private int lastIndex = -1; // last selected index when using arrows
@@ -791,6 +805,9 @@ public class VFilterSelect extends Composite implements Paintable, Field,
lastIndex = -1; // reset
}
+ if (selecting) {
+ suggestionPopup.menu.doPostFilterSelectedItemAction();
+ }
}
// Calculate minumum textarea width
@@ -818,6 +835,8 @@ public class VFilterSelect extends Composite implements Paintable, Field,
}
public void onSuggestionSelected(FilterSelectSuggestion suggestion) {
+ selecting = false;
+
currentSuggestion = suggestion;
String newKey;
if (suggestion.key.equals("")) {
@@ -881,15 +900,18 @@ public class VFilterSelect extends Composite implements Paintable, Field,
case KeyCodes.KEY_UP:
case KeyCodes.KEY_PAGEDOWN:
case KeyCodes.KEY_PAGEUP:
- if (suggestionPopup.isAttached()) {
- break;
- } else {
+ if (!suggestionPopup.isAttached()) {
// open popup as from gadget
filterOptions(-1, "");
lastFilter = "";
tb.selectAll();
- break;
}
+ break;
+ case KeyCodes.KEY_TAB:
+ if (suggestionPopup.isAttached()) {
+ filterOptions(currentPage, tb.getText());
+ }
+ break;
}
}
@@ -914,8 +936,16 @@ public class VFilterSelect extends Composite implements Paintable, Field,
filterOptions(currentPage - 1, lastFilter);
}
break;
- case KeyCodes.KEY_ENTER:
case KeyCodes.KEY_TAB:
+ if (suggestionPopup.isAttached()) {
+ filterOptions(currentPage);
+ }
+ // onBlur() takes care of the rest
+ break;
+ case KeyCodes.KEY_ENTER:
+ if (suggestionPopup.isAttached()) {
+ filterOptions(currentPage);
+ }
suggestionPopup.menu.doSelectedItemAction();
break;
}
@@ -1016,10 +1046,8 @@ public class VFilterSelect extends Composite implements Paintable, Field,
public void onBlur(BlurEvent event) {
focused = false;
- if (!suggestionPopup.isAttached() || suggestionPopup.isJustClosed()) {
- // typing so fast the popup was never opened, or it's just closed
- suggestionPopup.menu.doSelectedItemAction();
- }
+ // much of the TAB handling takes place here
+ suggestionPopup.menu.doSelectedItemAction();
if (selectedOptionKey == null) {
setPromptingOn();
}