我的工具栏中的两个下拉菜单出现视觉故障。当我:
将鼠标指针滚动到
File
下拉菜单按钮上...滚动到
Options
下拉菜单按钮...完全滚出工具栏...
文件下拉按钮仍然突出显示,尽管它似乎没有成为焦点。Options
如果您从 滚动到File
,然后离开工具栏,选项下拉菜单也会发生这种情况。
这是创建ToolBar
和的代码ToolItems
final ToolBar toolBar = new ToolBar (mainshell, SWT.DROP_DOWN);
toolBar.setSize(200,35);
toolBar.setLocation(0,0);
ToolItem File = new ToolItem(toolBar, SWT.DROP_DOWN);
File.setText("File");
final Menu FdropMenu = new Menu(mainshell, SWT.POP_UP);
File.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e1) {
if (e1.detail == SWT.ARROW) {
final ToolItem FtoolItem = (ToolItem) e1.widget;
final ToolBar FtoolBar = FtoolItem.getParent();
Point point = FtoolBar.toDisplay(new Point(e1.x, e1.y));
FdropMenu.setLocation(point.x, point.y);
FdropMenu.setVisible(true);
}
}
});
final MenuItem SaveMI = new MenuItem(FdropMenu, SWT.PUSH);
final MenuItem OpenMI = new MenuItem(FdropMenu, SWT.PUSH);
ToolItem itemDrop = new ToolItem(toolBar, SWT.DROP_DOWN);
itemDrop.setText("Options");
final Menu dropMenu = new Menu(mainshell, SWT.POP_UP);
itemDrop.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.detail == SWT.ARROW) {
final ToolItem toolItem = (ToolItem) e.widget;
final ToolBar toolBar = toolItem.getParent();
Point point = toolBar.toDisplay(new Point(e.x, e.y));
dropMenu.setLocation(point.x, point.y);
dropMenu.setVisible(true);
}
}
});
我不确定这是我的编程错误还是 SWT 中的错误。任何支持将不胜感激。