TableClickForwarder add-on

Hi fellow developers,

have you ever been annoyed when adding a layout to your Table breaks the selection of rows? Well, that’s not a problem any more since I just released the TableClickForwarder 0.0.1 add-on!

In all it’s simplicity, it is an extension which just adds mouse down/up handlers for any component, and dispatches these events to the parent TD within your Table.

Please try it out and tell what you think!

The download link:
http://vaadin.com/directory/#addon/tableclickforwarder

-tepi

It works fine. Currently i try to do is: Is the element a button, the event should not pass.
So i tried onMouseUp

if (el == null ||el instanceof ButtonElement)
    {          return;    }

The element is always [object HTMLTableCellElement]
, altough i pressed a label or button

EDIT: More Infos:

I have a table cell with a HorizontalLayout. The HorizontalLayout contains a Label and a Button. How can i different a click on the button or label with the element el? If the button is clicked, i don’t want pass the event (don’t select the row)

Oh I see. I think the problem is that the extension will pass on any mouse down/up events from the contained components. no matter which components they are. I should add an ‘ignore’ for buttons etc.

That would be great :). I tried this, but i’am too new on GWT and Vaadin.I had no sucess

Hi Teppo,

thanks for that addon, this is quite useful for tables with some custom content. I’m also wondering how you decide which kind of Element in the layout is clicked, maybe useful not only for buttons but also for textfields, checkboxes, etc.

-marita

Hi,

yeah, seems it’s going to be a bit problematic to decide when to dispatch the event and when not. Currently there is no ‘filtering’ so probably any click events within any components will go through, which is not that nice if you have some buttons and fields in the cell.

Obviously the issue is trivial if you only have a button/field in the cell - just don’t add the extension for that component.

I’ll see what I could do to make the forwarding more reasonable, although I’d hate to add explicit checks for all kinds of fields etc. into the code…

-tepi

could you post a snippet how to check for the kind of fields?

The check has to be done within the client-side class of the extension - basically you just need to check the type of the event source.

I released a new version (0.0.2) of the add-on. It will now ignore all events which originate from anything extending the Focusable interface on the client side. This includes e.g. buttons, textfields, checkboxes and should include all vaadin fields.

Please try it out and let me know if the solution is good enough, thanks.

will do, thanks a lot

Hello,

Firstly thanks for this great add-on.

One question (problem).
I have click listener on table:

table.addItemClickListener(new ItemClickEvent.ItemClickListener() {
    public void itemClick(ItemClickEvent event) {
        if (event.isDoubleClick()) {
            showDetail();
        }
    }
}); 

But double click is not provide from VerticalLayout (component in cell) to table click listener.

Hi Lukas,

and thanks for noting this. The extension does not currently handle double click events, only normal mouse clicks (left/right button and possible modified keys). I added the support for double click events and will publish a new version once I’ve tested it.

Hello,

any new info about double-clicks?

Hello Teppo,

Do you plan any new version with doubleclick support, or this project is dead?

-lukas

I would like to link this thread to this one:
https://vaadin.com/forum/#!/thread/8627834

This plugin looks like the solution to problems I am having with row selection and context menus in tables with layouts in cells. I tried it on Vaadin 7.3.6 but it doesn’t seem to be working. I added traces in a local copy of the plugin and verified the mouse events are being forwarded to the table in the DOM on the client side, but the table is not receiving those events on the server side. A colleague also tryed running the demo on Vaadin 7.3.6 and could not get that to work with row selection either. Is this a known issue on 7.3.6?

Hello Teppo,
I can confirm that the plugin is broken with Vaadin 7.3.1 (works with 7.3.0). I just did a sample project setup with this add on. The commit which causes this bug is this one: https://github.com/vaadin/vaadin/commit/6877a4d8802f9fae2b54e390e5171a1df705253d
See also: https://vaadin.com/forum#!/thread/9187304
Any solution would be nice!

Hello Teppo,

the add-on is still not working with Vaadin 7.4.1.
I did some analyse of the issue and the step:


TableClickForwarder
.
java


[i]
el = is the clicked cell of the row for selecting

el.dispatchEvent(Document.get().createMouseDownEvent(0, e.getScreenX(), e.getScreenY(), e.getClientX(), e.getClientY(), e.isControlKeyDown(), e.isAltKeyDown(), e.isShiftKeyDown(), e.isMetaKeyDown(), e.getNativeButton()));
[/i]

not select the whole row, just set focus to the table row. I think, the table component not catches the event (mouse down / focus etc) and the not know about the selection.
Can somebody fix the issue?

Thank you very much.

Best Regards.
Robert