Search code examples
gwtcontextmenucelltable

How to create a Right click drop down menu for GWT cell table


I have a cell table in GWT. I need to create a Right click on the rows in the Cell table. I have tried various methods but it isn't working. Can someone please help!


Solution

  • You can do something like this:

    myTable.addCellPreviewHandler(new Handler<MyObject>() {
    
        @Override
        public void onCellPreview(CellPreviewEvent<MyObject> event) {
            if (event.getNativeEvent().getButton() == NativeEvent.BUTTON_RIGHT) {
                event.getNativeEvent().stopPropagation();
                // do something instead with myObject (event.getValue()) or
                // with this row (event.getIndex())
            }
        }
    
    });