|
2 | 2 |
|
3 | 3 | import com.google.gwt.event.dom.client.ClickEvent; |
4 | 4 | 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; |
5 | 7 | import com.google.gwt.event.shared.HandlerRegistration; |
6 | 8 | import com.google.gwt.regexp.shared.MatchResult; |
7 | 9 | import com.google.gwt.regexp.shared.RegExp; |
8 | 10 | import com.google.gwt.safehtml.shared.SafeHtml; |
9 | 11 | import com.google.gwt.user.client.ui.HTMLPanel; |
10 | | -import com.vaadin.polymer.PolymerElement; |
11 | | -import com.vaadin.polymer.PolymerFunction; |
12 | 12 | import jsinterop.base.Js; |
| 13 | +import com.vaadin.polymer.elemental.Function; |
| 14 | +import com.vaadin.polymer.elemental.HTMLElement; |
13 | 15 |
|
14 | 16 | public class PolymerWidget extends HTMLPanel { |
15 | 17 |
|
| 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 | + |
16 | 39 | public PolymerWidget(String tag, String src, String html) { |
17 | 40 | super(tag, html); |
18 | 41 | Polymer.ensureCustomElement(getElement(), src); |
@@ -78,7 +101,11 @@ public HandlerRegistration addClickHandler(ClickHandler handler) { |
78 | 101 | return addDomHandler(handler, ClickEvent.getType()); |
79 | 102 | } |
80 | 103 |
|
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) { |
82 | 109 | Polymer.ready(getElement(), f); |
83 | 110 | } |
84 | 111 |
|
@@ -117,4 +144,3 @@ public void updateStyles() { |
117 | 144 | element.updateStyles(); |
118 | 145 | } |
119 | 146 | } |
120 | | - |
|
0 commit comments