import java.util.Map;\r
\r
import com.google.gwt.dom.client.NativeEvent;\r
-import com.google.gwt.event.dom.client.ClickEvent;\r
-import com.google.gwt.event.dom.client.ClickHandler;\r
import com.google.gwt.event.dom.client.ContextMenuEvent;\r
import com.google.gwt.event.dom.client.ContextMenuHandler;\r
import com.google.gwt.event.dom.client.DomEvent;\r
import com.vaadin.terminal.gwt.client.MouseEventDetails;\r
import com.vaadin.terminal.gwt.client.Paintable;\r
\r
-public abstract class ClickEventHandler implements ClickHandler,\r
- DoubleClickHandler, ContextMenuHandler, MouseUpHandler {\r
+public abstract class ClickEventHandler implements DoubleClickHandler,\r
+ ContextMenuHandler, MouseUpHandler {\r
\r
- private HandlerRegistration clickHandlerRegistration;\r
private HandlerRegistration doubleClickHandlerRegistration;\r
private HandlerRegistration mouseUpHandlerRegistration;\r
private HandlerRegistration contextMenuHandlerRegistration;\r
// Handle registering/unregistering of click handler depending on if\r
// server side listeners have been added or removed.\r
if (hasEventListener()) {\r
- if (clickHandlerRegistration == null) {\r
- clickHandlerRegistration = registerHandler(this, ClickEvent\r
- .getType());\r
+ if (mouseUpHandlerRegistration == null) {\r
mouseUpHandlerRegistration = registerHandler(this, MouseUpEvent\r
.getType());\r
contextMenuHandlerRegistration = registerHandler(this,\r
DoubleClickEvent.getType());\r
}\r
} else {\r
- if (clickHandlerRegistration != null) {\r
+ if (mouseUpHandlerRegistration != null) {\r
// Remove existing handlers\r
- clickHandlerRegistration.removeHandler();\r
doubleClickHandlerRegistration.removeHandler();\r
mouseUpHandlerRegistration.removeHandler();\r
contextMenuHandlerRegistration.removeHandler();\r
contextMenuHandlerRegistration = null;\r
mouseUpHandlerRegistration = null;\r
doubleClickHandlerRegistration = null;\r
- clickHandlerRegistration = null;\r
\r
}\r
}\r
clickEventIdentifier);\r
}\r
\r
- public void onClick(ClickEvent event) {\r
- if (hasEventListener()) {\r
- fireClick(event.getNativeEvent());\r
- }\r
- }\r
-\r
protected void fireClick(NativeEvent event) {\r
ApplicationConnection client = getApplicationConnection();\r
String pid = getApplicationConnection().getPid(paintable);\r
// occured on this element before this mouseup and that no mouseup\r
// has occured anywhere after that.\r
if (hasEventListener()) {\r
- if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {\r
- // "Click" with right or middle button\r
- fireClick(event.getNativeEvent());\r
-\r
- }\r
+ // "Click" with left, right or middle button\r
+ fireClick(event.getNativeEvent());\r
}\r
}\r
\r
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:GridLayout: Click on This is label 1</td>
+ <td>exact:GridLayout: left left click on This is label 1</td>
</tr>
<tr>
<td>mouseClick</td>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:GridLayout: Click on This is tf5</td>
+ <td>exact:GridLayout: left left click on This is tf5</td>
</tr>
<tr>
<td>mouseClick</td>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:GridLayout: Click on <none></td>
+ <td>exact:GridLayout: left left click on <none></td>
</tr>
<!--VerticalLayout-->
<tr>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:VerticalLayout: Click on This is tf6</td>
+ <td>exact:VerticalLayout: left left click on This is tf6</td>
</tr>
<tr>
<td>mouseClick</td>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:VerticalLayout: Click on This is label 3</td>
+ <td>exact:VerticalLayout: left left click on This is label 3</td>
</tr>
<!--AbsoluteLayout-->
<tr>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:AbsoluteLayout: Click on A button with its own click listener</td>
+ <td>exact:AbsoluteLayout: left left click on A button with its own click listener</td>
</tr>
<tr>
<td>mouseClick</td>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:AbsoluteLayout: Click on This is its caption</td>
+ <td>exact:AbsoluteLayout: left click on This is its caption</td>
</tr>
<!--CssLayout-->
<tr>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VLabel[0]</td>
- <td>exact:CSSLayout: Click on This is its caption</td>
+ <td>exact:CSSLayout: left click on This is its caption</td>
</tr>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:CSSLayout: Click on This is its caption</td>
+ <td>exact:CSSLayout: left click on This is its caption</td>
</tr>
<tr>
<td>click</td>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:CSSLayout: Click on A button with its own click listener</td>
+ <td>exact:CSSLayout: left click on A button with its own click listener</td>
</tr>
</tbody></table>
</body>
al.addListener(new LayoutClickListener() {
public void layoutClick(LayoutClickEvent event) {
- logLayoutClick("AbsoluteLayout", event.getChildComponent());
+ logLayoutClick("AbsoluteLayout", event);
}
});
cl.addListener(new LayoutClickListener() {
public void layoutClick(LayoutClickEvent event) {
- logLayoutClick("CSSLayout", event.getChildComponent());
+ logLayoutClick("CSSLayout", event);
}
});
gl.addListener(new LayoutClickListener() {
public void layoutClick(LayoutClickEvent event) {
- logLayoutClick("GridLayout", event.getChildComponent());
+ logLayoutClick("GridLayout", event);
}
});
gl.setRowExpandRatio(3, 1);
return wrap(gl, "GridLayout");
}
- protected void logLayoutClick(String layout, Component comp) {
+ protected void logLayoutClick(String layout, LayoutClickEvent event) {
String target = "<none>";
- if (comp != null) {
- target = comp.getCaption();
- if (target == null && comp instanceof Label) {
- target = ((Label) comp).getValue().toString();
+ Component component = event.getChildComponent();
+ if (component != null) {
+ target = component.getCaption();
+ if (target == null && component instanceof Label) {
+ target = ((Label) component).getValue().toString();
}
}
- log.log(layout + ": Click on " + target);
+ String button = "left";
+ if (event.getButton() == event.BUTTON_RIGHT) {
+ button = "right";
+ } else if (event.getButton() == event.BUTTON_MIDDLE) {
+ button = "middle";
+
+ }
+ String type = "click";
+ if (event.isDoubleClick()) {
+ type = "double-click";
+ }
+ log.log(layout + ": " + button + " " + type + " on " + target);
}
gl.addListener(new LayoutClickListener() {
public void layoutClick(LayoutClickEvent event) {
- logLayoutClick("VerticalLayout", event.getChildComponent());
+ logLayoutClick("VerticalLayout", event);
}
});