CTabFolder menu problem [message #1385255] |
Thu, 05 June 2014 08:28 |
Octavian Motataeanu Messages: 2 Registered: June 2014 |
Junior Member |
|
|
When setting the menu on a CTabFolder component, the popup is displayed wherever the user right-clicks inside a CTabItem's content, instead of just showing the menu on right-click on tab item titles.
Code snippet:
RWT start point:
public class EntryPointCTab implements EntryPoint {
@Override
public int createUI() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Show CTabFolder");
ShowCTabFolder content = new ShowCTabFolder();
content.createContents(shell);
shell.open();
return 0;
}
}
SWT start point:
public class SWTEntryPoint {
public static void main(String[] args) {
new SWTEntryPoint().run();
}
/**
* Runs the application
*/
public void run() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Show CTabFolder");
ShowCTabFolder content = new ShowCTabFolder();
content.createContents(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Common code:
public class ShowCTabFolder {
private CTabFolder tabFolder;
/**
* Creates the window's contents
*
* @param shell
* the parent shell
*/
public void createContents(Shell shell) {
shell.setLayout(new GridLayout(1, true));
// Create the tabs
tabFolder = new CTabFolder(shell, SWT.TOP);
tabFolder.setLayout(new GridLayout());
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
Menu tabfmenu = new Menu(tabFolder);
MenuItem tfmi1 = new MenuItem(tabfmenu, SWT.POP_UP);
tfmi1.setText("Menu popup");
tabFolder.setMenu(tabfmenu);
// Create an actual tab
CTabItem tab1 = new CTabItem(tabFolder, SWT.NONE);
tab1.setText("Tab (1)");
Composite tab1comp = new Composite(tabFolder, SWT.NONE);
tab1comp.setLayoutData(new GridData(GridData.FILL_BOTH));
tab1comp.setLayout(new GridLayout());
tab1comp.setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_BLUE));
Button btn1 = new Button(tab1comp, SWT.PUSH);
btn1.setText("Some text");
new Text(tab1comp, SWT.NONE);
tab1.setControl(tab1comp);
}
}
If you right click on the button or just a random location of the ctabitem composite, the menu is displayed. This does not happen in RCP. Replace the CTabFolder and CTabItem with normal TabFolder and TabItem and it will behave normally, displaying the menu like in RCP.
I am assuming this is a bug, but posted here to make sure I am not wrong or do not make a duplicate in bugzilla.
If this is a bug, is there any quick way arround it?
P.S: When dealing with this problem, I also noticed that if I have a TreeViewer set in the ctabitem content, the problem can be avoided by firs selecting an item in the table, and then right clicking will display the menu of the table, not the CTabFolder. But this still leaves the problem when right-clicking without selecting a tree item, the CTabFolder menu will be displayed instead.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02772 seconds