Skip to content

Commit 12227cf

Browse files
committed
Add TapEvents to widgets
1 parent 81e7236 commit 12227cf

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

lib/com/vaadin/polymer/PolymerWidget.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,40 @@
22

33
import com.google.gwt.event.dom.client.ClickEvent;
44
import com.google.gwt.event.dom.client.ClickHandler;
5+
import com.google.gwt.event.dom.client.MouseEvent;
6+
import com.google.gwt.event.shared.EventHandler;
57
import com.google.gwt.event.shared.HandlerRegistration;
68
import com.google.gwt.regexp.shared.MatchResult;
79
import com.google.gwt.regexp.shared.RegExp;
810
import com.google.gwt.safehtml.shared.SafeHtml;
911
import com.google.gwt.user.client.ui.HTMLPanel;
10-
import com.vaadin.polymer.PolymerElement;
11-
import com.vaadin.polymer.PolymerFunction;
1212
import jsinterop.base.Js;
13+
import com.vaadin.polymer.elemental.Function;
14+
import com.vaadin.polymer.elemental.HTMLElement;
1315

1416
public class PolymerWidget extends HTMLPanel {
1517

18+
public interface TapHandler extends EventHandler {
19+
void onTap(TapEvent event);
20+
}
21+
22+
public static class TapEvent extends MouseEvent<TapHandler> {
23+
private static final Type<TapHandler> TYPE = new Type<TapHandler>("tap", new TapEvent());
24+
25+
public static Type<TapHandler> getType() {
26+
return TYPE;
27+
}
28+
protected TapEvent() {
29+
}
30+
31+
public final Type<TapHandler> getAssociatedType() {
32+
return TYPE;
33+
}
34+
protected void dispatch(TapHandler handler) {
35+
handler.onTap(this);
36+
}
37+
}
38+
1639
public PolymerWidget(String tag, String src, String html) {
1740
super(tag, html);
1841
Polymer.ensureCustomElement(getElement(), src);
@@ -78,7 +101,11 @@ public HandlerRegistration addClickHandler(ClickHandler handler) {
78101
return addDomHandler(handler, ClickEvent.getType());
79102
}
80103

81-
public void ready(PolymerFunction<?, ?> f) {
104+
public HandlerRegistration addTapHandler(TapHandler handler) {
105+
return addDomHandler(handler, TapEvent.getType());
106+
}
107+
108+
public void ready(Function<?, ?> f) {
82109
Polymer.ready(getElement(), f);
83110
}
84111

@@ -117,4 +144,3 @@ public void updateStyles() {
117144
element.updateStyles();
118145
}
119146
}
120-

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gwt-api-generator",
3-
"version": "1.9.1",
3+
"version": "1.9.3",
44
"description": "",
55
"author": "Vaadin Ltd",
66
"license": "Apache License 2.0",

0 commit comments

Comments
 (0)