]> source.dussan.org Git - vaadin-framework.git/commitdiff
Clarification for GridContextClickEvent
authorIlia Motornyi <elmot@vaadin.com>
Mon, 10 Jul 2017 11:03:03 +0000 (14:03 +0300)
committerGitHub <noreply@github.com>
Mon, 10 Jul 2017 11:03:03 +0000 (14:03 +0300)
documentation/components/components-grid.asciidoc
server/src/main/java/com/vaadin/ui/Grid.java

index 6d73da72dffb8b26c6028826a2e9b023a8254087..1cd231aa82a797001cc6e2d8ef199a7ccade839a 100644 (file)
@@ -237,7 +237,6 @@ with an [interfacename]#ItemClickListener#. The [classname]#ItemClickEvent#
 object contains various information, most importantly the ID of the clicked row
 and column.
 
-
 [source, java]
 ----
 grid.addCellClickListener(event ->
@@ -250,7 +249,16 @@ The focus indication is themed so that the focused cell has a visible focus
 indicator style by default, while the row does not. You can enable row focus, as
 well as disable cell focus, in a custom theme. See <<components.grid.css>>.
 
+[[components.grid.right.clicks]]
+=== Right-clicks
+Right-clicks are supported similar way via `addContextClickListener()` method
 
+[source, java]
+----
+  grid.addContextClickListener(event -> Notification.show(
+        ((GridContextClickEvent<Person>)event).getItem() + " Clicked")
+  );
+----
 
 [[components.grid.columns]]
 == Configuring Columns
index 28b7ebcc60c980aa6bafc7b398c47d9ff44909ce..141130b7a21abc5cdc0c9eb23bbb1e7e33ce8ab2 100644 (file)
@@ -401,6 +401,13 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
     /**
      * ContextClickEvent for the Grid Component.
      *
+     * <p>
+     * Usage:
+     * <pre>
+     * grid.addContextClickListener(event -&gt; Notification.show(
+     *       ((GridContextClickEvent&lt;Person&gt;)event).getItem() + " Clicked")
+     * );
+     * </pre>
      * @param <T>
      *            the grid bean type
      */
@@ -3376,6 +3383,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
      * @param listener
      *            the item click listener, not null
      * @return a registration for the listener
+     * @see #addContextClickListener
      */
     public Registration addItemClickListener(
             ItemClickListener<? super T> listener) {
@@ -3383,6 +3391,24 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
                 listener, ITEM_CLICK_METHOD);
     }
 
+    /**
+     * Adds a context click listener that gets notified when a context click
+     * happens.
+     *
+     * @param listener
+     *            the context click listener to add, not null
+     *            actual event provided to the listener is {@link GridContextClickEvent}
+     * @return a registration object for removing the listener
+     *
+     * @since 8.1
+     * @see #addItemClickListener
+     * @see Registration
+     */
+    @Override
+    public Registration addContextClickListener(ContextClickEvent.ContextClickListener listener) {
+        return super.addContextClickListener(listener);
+    }
+
     /**
      * Registers a new column visibility change listener.
      *