Hi all.
I have come across the following issue.
I have a js web application which I had decided to rewrite using GWT.
So far everything goes smoothly except for one small problem: there's
a search form that consists of a single text input. I have to simulate
html5 "placeholder" attribute: to remove the fields' default value on
focus, and to show default value again on blur if the input is left
blank.
I tried to implement it this way:
// query-search-form - that input id
DOM.setEventListener(DOM.getElementById("query-search-form"), new
EventListener() {
public void onBrowserEvent(Event event) {
if (event.getTypeInt() == Event.ONFOCUS) {
Window.alert("it handles!"); // doesn't work
}
GWT.log("does any event catched at all?"); // doesn't work.
looks like it doesn't catch any event at all
}
});
Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
public void onPreviewNativeEvent(Event.NativePreviewEvent preview)
{
NativeEvent event = preview.getNativeEvent();
// seems like it catches all "general" events, like "click",
"mouseon", "mouseover" and so on, but not "focus" or "blur"
GWT.log("what type of event has been captured? " +
event.getType());
Element input = event.getEventTarget().cast();
if (event.getType().equalsIgnoreCase("focus") &&
input.getId().equals("query-search-form")) {
Window.alert("gotcha!"); // doesn't work
return;
}
preview.consume();
}
});
Any suggestions?
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.