如何使用 JFace MenuManager 将文本框添加到子菜单?
How to add a text box to a submenu with JFace MenuManager?
我想在菜单管理器中添加一个文本字段。我需要在我的子菜单中显示一个文本框而不是选项。谁能告诉我如何在子菜单中添加文本框。
代码:
IMenuManager submenu1 = new MenuManager("Enter Value");
submenu1.add(new Action("", SWT.BORDER) { @Override public void run() { } });
contextMenu.add(submenu1);
我想在此子菜单中显示文本框
恕我直言,无法将 SWT 控件(如 Combo、Text 等)添加为菜单项,但您可以将 SWT 控件添加为工具栏项。
查看文档here它说
public abstract class ControlContribution
extends ContributionItem
An abstract contribution item implementation for adding an arbitrary SWT control to a tool bar. Note, however, that these items cannot be contributed to menu bars.
The createControl framework method must be implemented by concrete subclasses.
检查此 post Eclipse RCP application custom toolbar 以了解如何将 SWT 控件添加为工具栏项。
我想在菜单管理器中添加一个文本字段。我需要在我的子菜单中显示一个文本框而不是选项。谁能告诉我如何在子菜单中添加文本框。
代码:
IMenuManager submenu1 = new MenuManager("Enter Value");
submenu1.add(new Action("", SWT.BORDER) { @Override public void run() { } });
contextMenu.add(submenu1);
我想在此子菜单中显示文本框
恕我直言,无法将 SWT 控件(如 Combo、Text 等)添加为菜单项,但您可以将 SWT 控件添加为工具栏项。
查看文档here它说
public abstract class ControlContribution extends ContributionItem
An abstract contribution item implementation for adding an arbitrary SWT control to a tool bar. Note, however, that these items cannot be contributed to menu bars.
The createControl framework method must be implemented by concrete subclasses.
检查此 post Eclipse RCP application custom toolbar 以了解如何将 SWT 控件添加为工具栏项。