Exemplo n.º 1
0
  /**
   * 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.
   *
   * <p>The mnemonic indicator (character '&amp;') is not displayed in a tool tip. To display a
   * single '&amp;' in the tool tip, the character '&amp;' can be escaped by doubling it in the
   * string.
   *
   * <p>NOTE: Tooltips are currently not shown for top-level menu items in the {@link
   * Shell#setMenuBar(Menu) shell menubar} on Windows, Mac, and Ubuntu Unity desktop.
   *
   * @param toolTip the new tool tip text (or null)
   * @exception SWTException
   *     <ul>
   *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
   *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
   *     </ul>
   *
   * @since 3.104
   */
  public void setToolTipText(String toolTip) {
    checkWidget();

    if (toolTip == null && itemToolTip != null) {
      itemToolTip.setVisible(false);
      itemToolTip = null;
    }

    if (toolTip == null
        || toolTip.trim().length() == 0
        || (itemToolTip != null && toolTip.equals(itemToolTip.getMessage()))) return;

    itemToolTip = new MenuItemToolTip(this.getParent().getShell());
    itemToolTip.setMessage(toolTip);
    itemToolTip.setVisible(false);
  }
Exemplo n.º 2
0
 void hideToolTip() {
   if (itemToolTip == null) return;
   itemToolTip.setVisible(false);
 }
Exemplo n.º 3
0
 /**
  * Returns the receiver's tool tip text, or null if it has not been set.
  *
  * @return the receiver's tool tip text
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  *
  * @since 3.104
  */
 public String getToolTipText() {
   checkWidget();
   return (itemToolTip == null) ? null : itemToolTip.getMessage();
 }
Exemplo n.º 4
0
 void showTooltip(int x, int y) {
   if (itemToolTip == null) return;
   itemToolTip.setLocation(x, y);
   itemToolTip.setVisible(true);
 }