I have similar problem but slightly different scenario. Here is what I have. I have a tree and one of the column’s content is CssLayout ( to add a String and a button). Normally (if this column content is just a string) my context-menu works just fine, but when I have CssLayout as column content and when I place mouse on THIS column and do a right click, instead of my context-menu appearing, browser right-click menu is appearing. On any other column right click does produce my context-menu.
Please suggest any solutions for this issue.
Here is the example code that demonstrate the issue.
package com.example.helloworld;
import com.vaadin.Application;
import com.vaadin.event.Action;
import com.vaadin.ui.Button;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class HelloworldApplication extends Application {
static final Action ACTION_MARK = new Action(“Mark”);
static final Action ACTION_UNMARK = new Action(“Unmark”);
static final Action ACTION_LOG = new Action(“Save”);
static final Action ACTIONS_UNMARKED = new Action
{ ACTION_MARK,
ACTION_LOG };
static final Action ACTIONS_MARKED = new Action
{ ACTION_UNMARK,
ACTION_LOG };
@Override
public void init() {
Window mainWindow = null;
mainWindow = new Window("My Window");
Panel mainPanel = new Panel();
mainPanel.setWidth("100%");
mainPanel.setHeight("100%");
mainPanel.setStyleName(Panel.STYLE_LIGHT);
mainWindow.setContent(mainPanel);
setMainWindow(mainWindow);
setTheme("myTheme");
/* Create the table with a caption. */
Table table = new Table("This is my Table");
/* Define the names and data types of columns.
* The "default value" parameter is meaningless here. */
table.addContainerProperty("First Name", String.class, null);
table.addContainerProperty("Last Name", String.class, null);
table.addContainerProperty("Year", Integer.class, null);
table.addContainerProperty("Description", CssLayout.class, null);
CssLayout description1 = new CssLayout();
description1.addComponent(new Label("Some one"));
description1.addComponent(new Button("Very Special"));
CssLayout description2 = new CssLayout();
description2.addComponent(new Label("Some one"));
description2.addComponent(new Button("Very Special"));
CssLayout description3 = new CssLayout();
description3.addComponent(new Label("Some one"));
description3.addComponent(new Button("Very Special"));
CssLayout description4 = new CssLayout();
description4.addComponent(new Label("Some one"));
description4.addComponent(new Button("Very Special"));
CssLayout description5 = new CssLayout();
description5.addComponent(new Label("Some one"));
description5.addComponent(new Button("Very Special"));
CssLayout description6 = new CssLayout();
description6.addComponent(new Label("Some one"));
description6.addComponent(new Button("Very Special"));
/* Add a few items in the table. */
table.addItem(new Object[] {
"Nicolaus","Copernicus",new Integer(1473), description1}, new Integer(1));
table.addItem(new Object[] {
"Tycho", "Brahe", new Integer(1546), description2}, new Integer(2));
table.addItem(new Object[] {
"Giordano","Bruno", new Integer(1548), description3}, new Integer(3));
table.addItem(new Object[] {
"Galileo", "Galilei", new Integer(1564), description4}, new Integer(4));
table.addItem(new Object[] {
"Johannes","Kepler", new Integer(1571), description5}, new Integer(5));
table.addItem(new Object[] {
"Isaac", "Newton", new Integer(1643), description6}, new Integer(6));
// Actions (a.k.a context menu)
table.addActionHandler(new Action.Handler() {
public Action[] getActions(Object target, Object sender) {
return ACTIONS_MARKED;
}
public void handleAction(Action action, Object sender, Object target) {
if (ACTION_MARK.equals(action)) {
} else if (ACTION_UNMARK.equals(action)) {
} else if (ACTION_LOG.equals(action)) {
}
}
});
VerticalLayout panelContent = (VerticalLayout)mainPanel.getContent();
panelContent.setWidth("100%");
//panelContent.setHeight("100%");
VerticalLayout allCompPane = new VerticalLayout();
panelContent.addComponent(allCompPane);
allCompPane.addComponent(table);
}
Thanks
Raj.