From 5254061ed4df93d579b114f1fa665712e5458950 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 17 Dec 2009 11:16:42 +0000 Subject: Fix for #3874 - Two click events is sent for a middle click in a layout svn changeset:10379/svn branch:6.2 --- .../tests/layouts/TestLayoutClickListeners.html | 20 +++++++------- .../tests/layouts/TestLayoutClickListeners.java | 32 +++++++++++++++------- 2 files changed, 32 insertions(+), 20 deletions(-) (limited to 'tests') diff --git a/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html index f488eb9a81..28635a9df7 100644 --- a/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html +++ b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html @@ -40,7 +40,7 @@ assertText vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] - exact:GridLayout: Click on This is label 1 + exact:GridLayout: left left click on This is label 1 mouseClick @@ -55,7 +55,7 @@ assertText vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] - exact:GridLayout: Click on This is tf5 + exact:GridLayout: left left click on This is tf5 mouseClick @@ -70,7 +70,7 @@ assertText vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] - exact:GridLayout: Click on <none> + exact:GridLayout: left left click on <none> @@ -86,7 +86,7 @@ assertText vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] - exact:VerticalLayout: Click on This is tf6 + exact:VerticalLayout: left left click on This is tf6 mouseClick @@ -101,7 +101,7 @@ assertText vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] - exact:VerticalLayout: Click on This is label 3 + exact:VerticalLayout: left left click on This is label 3 @@ -122,7 +122,7 @@ assertText vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] - exact:AbsoluteLayout: Click on A button with its own click listener + exact:AbsoluteLayout: left left click on A button with its own click listener mouseClick @@ -137,7 +137,7 @@ assertText vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] - exact:AbsoluteLayout: Click on This is its caption + exact:AbsoluteLayout: left click on This is its caption @@ -168,12 +168,12 @@ assertText vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VLabel[0] - exact:CSSLayout: Click on This is its caption + exact:CSSLayout: left click on This is its caption assertText vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] - exact:CSSLayout: Click on This is its caption + exact:CSSLayout: left click on This is its caption click @@ -193,7 +193,7 @@ assertText vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] - exact:CSSLayout: Click on A button with its own click listener + exact:CSSLayout: left click on A button with its own click listener diff --git a/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java index ecda096690..9a7dca7e30 100644 --- a/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java +++ b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java @@ -105,7 +105,7 @@ public class TestLayoutClickListeners extends AbstractTestCase { al.addListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { - logLayoutClick("AbsoluteLayout", event.getChildComponent()); + logLayoutClick("AbsoluteLayout", event); } }); @@ -137,7 +137,7 @@ public class TestLayoutClickListeners extends AbstractTestCase { cl.addListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { - logLayoutClick("CSSLayout", event.getChildComponent()); + logLayoutClick("CSSLayout", event); } }); @@ -160,22 +160,34 @@ public class TestLayoutClickListeners extends AbstractTestCase { 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); } @@ -187,7 +199,7 @@ public class TestLayoutClickListeners extends AbstractTestCase { gl.addListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { - logLayoutClick("VerticalLayout", event.getChildComponent()); + logLayoutClick("VerticalLayout", event); } }); -- cgit v1.2.3