Friday, October 24, 2014

Re: Send event for keydown

To show letters in uppercase in the input text, I've done:
----
  public static void applyMask(final TextBox textbox) {
    String style = textbox.getElement().getAttribute("style");
    textbox.getElement().setAttribute("style", style + ";text-transform:uppercase;");
----

And in the backend side, I've make the uppercase. It's faster, but it's only a visual effect.

Juan


On 24 October 2014 16:44, Thad Humphries <thad.humphries@gmail.com> wrote:
Yeah. That happens to me more often than I care to admit.  :) 

When I first started with GWT I wrestled with the same problem, and someone on this list showed me how to do it. As I recall, the key was adding the Scheduler (though this was before GWT 1.5 and it was called something else then).

On Friday, October 24, 2014 9:16:53 AM UTC-4, Marteijn Nouwens wrote:
This is what is now did But it feels off :-(

Op donderdag 23 oktober 2014 16:34:15 UTC+2 schreef Thad Humphries:
This KeyPressHandler will change the text to upper case as the user types:

public class ForceUpperCase implements KeyPressHandler {
  @Override
  public void onKeyPress(KeyPressEvent event) {
    final TextBoxBase tbb = (TextBoxBase) event.getSource();
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
       @Override
       public void execute() {
           tbb.setText(tbb.getText().toUpperCase());
       }
    });
  }
}

..

textBoxBase.addKeyPressHandler(new ForceUpperCase());


On Tuesday, October 21, 2014 7:49:57 AM UTC-4, Marteijn Nouwens wrote:
In a sub class for a textbox i try to convert lower case to upper case. This works ok but i would like to send the upper case as a Event.

// NativeEvent down = Document.get().createKeyDownEvent(false, false, true, false, keyCode);
// DomEvent.fireNativeEvent(down, this, this.getElement());

But this does not seem to trigger the browser event.

Now i do substring and set value. The user does not see this but i feel it's a bit overkill.

Anybody any ideas.?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment