org.eclipse.swt.widgets.MenuItem.setToolTipText()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中org.eclipse.swt.widgets.MenuItem.setToolTipText()方法的一些代码示例,展示了MenuItem.setToolTipText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setToolTipText()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.MenuItem
类名称:MenuItem
方法名:setToolTipText

[英]Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown. For a menu item that has a default tool tip, setting the tool tip text to an empty string replaces the default, causing no tool tip text to be shown.

The mnemonic indicator (character '&') is not displayed in a tool tip. To display a single '&' in the tool tip, the character '&' can be escaped by doubling it in the string.

NOTE: Tooltips are currently not shown for top-level menu items in the Shell#setMenuBar(Menu) on Windows, Mac, and Ubuntu Unity desktop.
[中]将接收者的工具提示文本设置为参数,该参数可能为空,表示将显示控件的默认工具提示。对于具有默认工具提示的菜单项,将工具提示文本设置为空字符串将替换默认值,从而不会显示工具提示文本。
助记符(字符“&”)不显示在工具提示中。要在工具提示中显示单个“&”,可以通过在字符串中加倍字符“&”进行转义。
注意:Windows、Mac和UbuntuUnity桌面上的Shell#setMenuBar(菜单)中的顶级菜单项目前没有显示工具提示。

代码示例

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciClosedFolder]);
item.setEnabled(enabledButton.getSelection());
if (tooltipButton.getSelection()) item.setToolTipText(ControlExample.getResourceString("Tooltip", item.getText() ));
hookListeners(item);
if (tooltipButton.getSelection()) item.setToolTipText(ControlExample.getResourceString("Tooltip", item.getText() ));
if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciOpenFolder]);
item.setEnabled(enabledButton.getSelection());
if (tooltipButton.getSelection()) item.setToolTipText(ControlExample.getResourceString("Tooltip", item.getText() ));
hookListeners(item);
item.setSelection(true);
item.setEnabled(enabledButton.getSelection());
if (tooltipButton.getSelection()) item.setToolTipText(ControlExample.getResourceString("Tooltip", item.getText() ));
hookListeners(item);
if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciTarget]);
item.setEnabled(enabledButton.getSelection());
if (tooltipButton.getSelection()) item.setToolTipText(ControlExample.getResourceString("Tooltip", item.getText()));
hookListeners(item);
item.setEnabled(enabledButton.getSelection());
hookListeners(subMenu);
if (tooltipButton.getSelection()) item.setToolTipText(ControlExample.getResourceString("Tooltip", item.getText() ));
createMenuItems(subMenu, createSubSubMenu, false);

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

item.setText(getMenuItemText("Cascade"));
if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciOpenFolder]);
if (tooltipButton.getSelection()) item.setToolTipText(ControlExample.getResourceString("Tooltip", item.getText() ));
hookListeners(item);
Menu dropDownMenu = new Menu(shell, SWT.DROP_DOWN | radioBehavior);

代码示例来源:origin: org.eclipse.platform/org.eclipse.tips.ui

private void loadActionMenu(Tip pTip) {
  if (fActionMenu != null) {
    fActionMenu.dispose();
  }
  fActionMenu = new Menu(fContentComposite.getShell(), SWT.POP_UP);
  pTip.getActions().subList(1, pTip.getActions().size()).forEach(action -> {
    MenuItem item = new MenuItem(fActionMenu, SWT.PUSH);
    item.setText(action.getText());
    item.setToolTipText(action.getTooltip());
    item.setText(action.getText());
    item.setImage(getActionImage(action.getTipImage()));
    item.addListener(SWT.Selection, e -> runTipAction(action));
  });
}

代码示例来源:origin: BiglySoftware/BiglyBT

if ((defaultValue instanceof String)
    || (defaultValue instanceof Number)) {
  item.setToolTipText(defaultValue.toString());

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.workbench.renderers.swt

item.setToolTipText(tooltip);
item.setSelection(getModel().isSelected());
item.setEnabled(getModel().isEnabled());

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.workbench.renderers.swt

@Override
protected void updateMenuItem() {
  MenuItem item = (MenuItem) widget;
  String text = getModel().getLocalizedLabel();
  if (text != null) {
    item.setText(text);
  } else {
    item.setText(""); //$NON-NLS-1$
  }
  final String tooltip = getModel().getLocalizedTooltip();
  item.setToolTipText(tooltip);
  item.setSelection(getModel().isSelected());
  item.setEnabled(getModel().isEnabled());
}

相关文章