import com.google.gwt.user.client.ui.TextBoxBase;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo;
+import com.vaadin.client.DeferredWorker;
import com.vaadin.client.WidgetUtil;
import com.vaadin.shared.EventId;
import com.vaadin.shared.ui.textfield.TextFieldConstants;
*
*/
public class VTextField extends TextBoxBase implements Field, ChangeHandler,
- FocusHandler, BlurHandler, KeyDownHandler {
+ FocusHandler, BlurHandler, KeyDownHandler, DeferredWorker {
/**
* The input node CSS classname.
}
possibleInputError = false;
}
+
+ @Override
+ public boolean isWorkPending() {
+ return scheduled;
+ }
}
ta.addListener(inputEventListener);
getLayout().addComponent(ta);
+ TextArea tat = new TextArea("Timeout 3s");
+ tat.addListener(inputEventListener);
+ tat.setTextChangeEventMode(TextChangeEventMode.TIMEOUT);
+ tat.setTextChangeTimeout(3000);
+ getLayout().addComponent(tat);
+
VaadinDeveloperNameField vd = new VaadinDeveloperNameField();
vd.addListener(inputEventListener);
getLayout().addComponent(vd);
--- /dev/null
+package com.vaadin.tests.components.textfield;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.TextAreaElement;
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class TextChangeEventsTest extends SingleBrowserTest {
+
+ @Test
+ public void textAreaWaitsForTextChangeEvents() {
+ openTestURL();
+
+ TextAreaElement taDefault = $(TextAreaElement.class)
+ .caption("Default text area").first();
+ taDefault.sendKeys("abc");
+ Assert.assertEquals(
+ "1. Text change event for Default text area, text content currently:'abc' Cursor at index:3",
+ getLogRow(0));
+
+ TextAreaElement taTimeout = $(TextAreaElement.class)
+ .caption("Timeout 3s").first();
+ taTimeout.sendKeys("abc");
+ Assert.assertEquals(
+ "2. Text change event for Timeout 3s, text content currently:'abc' Cursor at index:3",
+ getLogRow(0));
+
+ }
+
+ @Test
+ public void textFieldWaitsForTextChangeEvents() {
+ openTestURL();
+
+ TextFieldElement tfDefault = $(TextFieldElement.class)
+ .caption("Default").first();
+ tfDefault.sendKeys("abc");
+ Assert.assertEquals(
+ "1. Text change event for Default, text content currently:'abc' Cursor at index:3",
+ getLogRow(0));
+
+ TextFieldElement tfEager = $(TextFieldElement.class).caption("Eager")
+ .first();
+ tfEager.sendKeys("abc");
+ Assert.assertEquals(
+ "2. Text change event for Eager, text content currently:'abc' Cursor at index:3",
+ getLogRow(0));
+
+ TextFieldElement tfTimeout = $(TextFieldElement.class)
+ .caption("Timeout 3s").first();
+ tfTimeout.sendKeys("abc");
+ Assert.assertEquals(
+ "3. Text change event for Timeout 3s, text content currently:'abc' Cursor at index:3",
+ getLogRow(0));
+
+ }
+}