diff --git a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/CalendarEventGenerator.java b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/CalendarEventGenerator.java index b710b031a..47f50ece5 100644 --- a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/CalendarEventGenerator.java +++ b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/CalendarEventGenerator.java @@ -16,6 +16,7 @@ package com.google.zxing.web.generator.client; +import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; @@ -59,9 +60,11 @@ public class CalendarEventGenerator implements GeneratorSource { ListBox timeZones = new ListBox(); Date timePicker1PreviousDate = null; - public CalendarEventGenerator(final ChangeListener listener) { + public CalendarEventGenerator(final ChangeListener listener, + KeyPressHandler keyListener) { eventName.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED); eventName.addChangeListener(listener); + eventName.addKeyPressHandler(keyListener); datePicker1.setAnimationEnabled(true); datePicker2.setAnimationEnabled(true); timePicker2 @@ -70,6 +73,7 @@ public class CalendarEventGenerator implements GeneratorSource { buildTimeZoneList(); timeZones.setSelectedIndex(25); + timeZones.addKeyPressHandler(keyListener); timePicker1.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { Date time = timePicker1PreviousDate; diff --git a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/ContactInfoGenerator.java b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/ContactInfoGenerator.java index af6d599d4..6ab33608f 100644 --- a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/ContactInfoGenerator.java +++ b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/ContactInfoGenerator.java @@ -16,6 +16,7 @@ package com.google.zxing.web.generator.client; +import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.user.client.ui.ChangeListener; import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.TextBox; @@ -38,9 +39,11 @@ public class ContactInfoGenerator implements GeneratorSource { TextBox memo = new TextBox(); TextBox[] widgets = {name, company, tel, url, email, address, address2, memo}; - public ContactInfoGenerator(ChangeListener changeListener) { + public ContactInfoGenerator(ChangeListener changeListener, + KeyPressHandler keyListener) { for (TextBox w: widgets) { w.addChangeListener(changeListener); + w.addKeyPressHandler(keyListener); } } diff --git a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/EmailGenerator.java b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/EmailGenerator.java index 65e60c5cf..517a4ee7b 100644 --- a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/EmailGenerator.java +++ b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/EmailGenerator.java @@ -16,6 +16,7 @@ package com.google.zxing.web.generator.client; +import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.user.client.ui.ChangeListener; import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.TextBox; @@ -30,9 +31,10 @@ public class EmailGenerator implements GeneratorSource { Grid table = null; TextBox email = new TextBox(); - public EmailGenerator(ChangeListener listener) { + public EmailGenerator(ChangeListener listener, KeyPressHandler keyListener) { email.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED); email.addChangeListener(listener); + email.addKeyPressHandler(keyListener); } public String getName() { diff --git a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/Generator.java b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/Generator.java index 86947e988..d5b70361b 100644 --- a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/Generator.java +++ b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/Generator.java @@ -18,6 +18,8 @@ package com.google.zxing.web.generator.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.dom.client.Element; +import com.google.gwt.event.dom.client.KeyPressEvent; +import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.http.client.URL; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.Button; @@ -103,14 +105,14 @@ public class Generator implements EntryPoint { } private void loadGenerators() { - generators.add(new CalendarEventGenerator(changeListener)); - generators.add(new ContactInfoGenerator(changeListener)); - generators.add(new EmailGenerator(changeListener)); - generators.add(new GeoLocationGenerator(changeListener)); - generators.add(new PhoneNumberGenerator(changeListener)); - generators.add(new SmsAddressGenerator(changeListener)); + generators.add(new CalendarEventGenerator(changeListener, keyPressHandler)); + generators.add(new ContactInfoGenerator(changeListener, keyPressHandler)); + generators.add(new EmailGenerator(changeListener, keyPressHandler)); + generators.add(new GeoLocationGenerator(changeListener, keyPressHandler)); + generators.add(new PhoneNumberGenerator(changeListener, keyPressHandler)); + generators.add(new SmsAddressGenerator(changeListener, keyPressHandler)); generators.add(new TextGenerator(changeListener)); - generators.add(new UrlGenerator(changeListener)); + generators.add(new UrlGenerator(changeListener, keyPressHandler)); } public void setupLeftPanel() { @@ -237,4 +239,12 @@ public class Generator implements EntryPoint { } }; + public KeyPressHandler keyPressHandler = new KeyPressHandler() { + @Override + public void onKeyPress(KeyPressEvent event) { + if (event.getCharCode() == '\n' || event.getCharCode() == '\r') { + generate(); + } + } + }; } diff --git a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/GeoLocationGenerator.java b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/GeoLocationGenerator.java index d02c578c8..724a7e05f 100644 --- a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/GeoLocationGenerator.java +++ b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/GeoLocationGenerator.java @@ -16,6 +16,7 @@ package com.google.zxing.web.generator.client; +import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.http.client.URL; import com.google.gwt.maps.client.MapWidget; import com.google.gwt.maps.client.control.SmallMapControl; @@ -52,15 +53,19 @@ public class GeoLocationGenerator implements GeneratorSource, ChangeListener { Marker mapMarker = null; private ChangeListener changeListener; - public GeoLocationGenerator(ChangeListener listener) { + public GeoLocationGenerator(ChangeListener listener, + KeyPressHandler keyListener) { this.changeListener = listener; latitude.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED); - longitude.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED); latitude.addChangeListener(listener); latitude.addChangeListener(this); + latitude.addKeyPressHandler(keyListener); + longitude.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED); longitude.addChangeListener(listener); longitude.addChangeListener(this); + longitude.addKeyPressHandler(keyListener); query.addChangeListener(listener); + query.addKeyPressHandler(keyListener); } public String getName() { diff --git a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/PhoneNumberGenerator.java b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/PhoneNumberGenerator.java index e1e773096..17a78c53e 100644 --- a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/PhoneNumberGenerator.java +++ b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/PhoneNumberGenerator.java @@ -16,6 +16,7 @@ package com.google.zxing.web.generator.client; +import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.user.client.ui.ChangeListener; import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.TextBox; @@ -30,9 +31,11 @@ public class PhoneNumberGenerator implements GeneratorSource { Grid table = null; TextBox number = new TextBox(); - public PhoneNumberGenerator(ChangeListener listener) { + public PhoneNumberGenerator(ChangeListener listener, + KeyPressHandler keyListener) { number.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED); number.addChangeListener(listener); + number.addKeyPressHandler(keyListener); } public String getName() { diff --git a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/SmsAddressGenerator.java b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/SmsAddressGenerator.java index 97d86d3ab..f117e51e4 100644 --- a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/SmsAddressGenerator.java +++ b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/SmsAddressGenerator.java @@ -16,6 +16,7 @@ package com.google.zxing.web.generator.client; +import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.user.client.ui.ChangeListener; import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.TextArea; @@ -33,9 +34,11 @@ public class SmsAddressGenerator implements GeneratorSource { TextBox number = new TextBox(); TextArea message = new TextArea(); - public SmsAddressGenerator(ChangeListener listener) { + public SmsAddressGenerator(ChangeListener listener, + KeyPressHandler keyListener) { number.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED); number.addChangeListener(listener); + number.addKeyPressHandler(keyListener); message.addChangeListener(listener); } diff --git a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/UrlGenerator.java b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/UrlGenerator.java index cebe1b483..baa4b340f 100644 --- a/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/UrlGenerator.java +++ b/zxing.appspot.com/generator/src/com/google/zxing/web/generator/client/UrlGenerator.java @@ -16,6 +16,7 @@ package com.google.zxing.web.generator.client; +import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.user.client.ui.ChangeListener; import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.TextBox; @@ -30,9 +31,10 @@ public class UrlGenerator implements GeneratorSource { Grid table = null; TextBox url = new TextBox(); - public UrlGenerator(ChangeListener listener) { + public UrlGenerator(ChangeListener listener, KeyPressHandler keyListener) { url.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED); url.addChangeListener(listener); + url.addKeyPressHandler(keyListener); } public Grid getWidget() {