Question: Is it possible to show a right click menu on table items with SWT? The menu would be different for every item, e.g for some rows, some of the menu items would be enabled, for others, they would be disabled. So, each row would need its own menu, and when setting up the menu i'd need a way to identify which row I was working with.

Any ideas?

Answer: 
Listening for `SWT.MouseDown`, as suggested by @user4793956, is completely useless. The context menu is always brought up, no need to call `setVisible(true)`. Quite contrary, you need to cancel the `SWT.MenuDetect` event, if you do **not** want the menu to pop up.

This works for me:

```
// Create context menu
Menu menuTable = new Menu(table);
table.setMenu(menuTable);

// Create menu item
MenuItem miTest = new MenuItem(menuTable, SWT.NONE);
miTest.setText("Test Item");

// Do not show menu, when no item is selected
table.addListener(SWT.MenuDetect, new Listener() {
  @Override
  public void handleEvent(Event event) {
    if (table.getSelectionCount() <= 0) {
      event.doit = false;
    }
  }
});

```
```
    table = new DynamicTable(shell, SWT.BORDER | SWT.FULL_SELECTION);        
    table.addMenuDetectListener(new MenuDetectListener()
    {
        @Override
        public void menuDetected(MenuDetectEvent e)
        {                
           int index = table.getSelectionIndex();
           if (index == -1) 
             return; //no row selected

           TableItem item = table.getItem(index);
           item.getData(); //use this to identify which row was clicked.
           //The popup can now be displayed as usual using table.toDisplay(e.x, e.y)              
        }
    });

```

More details: <http://www.eclipsezone.com/eclipse/forums/t49734.html>