Adding menu to swt table [message #1066207] |
Mon, 01 July 2013 14:41 |
Chandrayya Kumarswamimath Messages: 26 Registered: August 2010 Location: Bangalore |
Junior Member |
|
|
I want to add same menu on multiple tables(SWT table). When user clicks on menu items, I want to detect the table associated with that menu. See the code below.
private void setMenu(Table table) {
Listener popUpListener = new Listener() {
@Override
public void handleEvent(Event event) {
MenuItem item = (MenuItem)event.widget;
Menu pare = item.getParent();
Decorations fdf = pare.getParent();
//Code to get table name or instance of table.
}
};
Menu menu = new Menu(table); // where table1 is your table
MenuItem item1 = new MenuItem(menu, SWT.PUSH);
item1.setText("Copy cell");
item1.addListener(SWT.Selection, popUpListener);
MenuItem item2 = new MenuItem(menu, SWT.PUSH);
item2.setText("Copy row");
item2.addListener(SWT.Selection, popUpListener);
MenuItem item3 = new MenuItem(menu, SWT.PUSH);
item3.setText("Copy column");
item3.addListener(SWT.Selection, popUpListener);
MenuItem item4 = new MenuItem(menu, SWT.PUSH);
item4.setText("Copy all");
item4.addListener(SWT.Selection, popUpListener);
table.setMenu(menu);
}
setMenu method is called multiple times sending the instances of table. How I can detect the table associated with the currently popped up menu in pop-up listener.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03906 seconds