Class ToolTip

java.lang.Object
org.eclipse.jface.window.ToolTip
Direct Known Subclasses:
DefaultToolTip

public abstract class ToolTip extends Object
This class gives implementors to provide customized tooltips for any control.
Since:
3.3
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Don't recreate the tooltip as long the mouse doesn't leave the area triggering the tooltip creation
    static final int
    Recreate the tooltip on every mouse move
  • Constructor Summary

    Constructors
    Constructor
    Description
    ToolTip(Control control)
    Create new instance which add TooltipSupport to the widget
    ToolTip(Control control, int style, boolean manualActivation)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Activate tooltip support for this control
    protected void
    This method is called after a tooltip is hidden.
    protected abstract Composite
    Creates the content area of the the tooltip.
    void
    Deactivate tooltip support for the underlying control
    Get the data restored under the key
    getLocation(Point tipSize, Event event)
    Get the display relative location where the tooltip is displayed.
    protected Object
    This method is called to check for which area the tooltip is created/hidden for.
    void
    Hide the currently active tool tip
    boolean
    Return if hiding on mouse down is set.
    boolean
    Return whether the tooltip respects bounds of the display.
    boolean
    Return whether the tooltip respects bounds of the monitor.
    void
    setData(String key, Object value)
    Restore arbitrary data under the given key
    void
    setHideDelay(int hideDelay)
    Set the hide delay.
    void
    setHideOnMouseDown(boolean hideOnMouseDown)
    If you don't want the tool tip to be hidden when the user clicks inside the tool tip set this to false.
    void
    setPopupDelay(int popupDelay)
    Set the popup delay.
    void
    setRespectDisplayBounds(boolean respectDisplayBounds)
    Set to false if display bounds should not be respected or to true if the tooltip is should repositioned to not overlap the display bounds.
    void
    setRespectMonitorBounds(boolean respectMonitorBounds)
    Set to false if monitor bounds should not be respected or to true if the tooltip is should repositioned to not overlap the monitors bounds.
    void
    Set the shift (from the mouse position triggered the event) used to display the tooltip.
    protected boolean
    Should the tooltip displayed because of the given event.
    void
    show(Point location)
    Start up the tooltip programmatically

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • RECREATE

      public static final int RECREATE
      Recreate the tooltip on every mouse move
      See Also:
    • NO_RECREATE

      public static final int NO_RECREATE
      Don't recreate the tooltip as long the mouse doesn't leave the area triggering the tooltip creation
      See Also:
  • Constructor Details

    • ToolTip

      public ToolTip(Control control)
      Create new instance which add TooltipSupport to the widget
      Parameters:
      control - the control on whose action the tooltip is shown
    • ToolTip

      public ToolTip(Control control, int style, boolean manualActivation)
      Parameters:
      control - the control to which the tooltip is bound
      style - style passed to control tooltip behavior
      manualActivation - true if the activation is done manually using show(Point)
      See Also:
  • Method Details

    • setData

      public void setData(String key, Object value)
      Restore arbitrary data under the given key
      Parameters:
      key - the key
      value - the value
    • getData

      public Object getData(String key)
      Get the data restored under the key
      Parameters:
      key - the key
      Returns:
      data or null if no entry is restored under the key
    • setShift

      public void setShift(Point p)
      Set the shift (from the mouse position triggered the event) used to display the tooltip.

      By default the tooltip is shifted 3 pixels to the right.

      Parameters:
      p - the new shift
    • activate

      public void activate()
      Activate tooltip support for this control
    • deactivate

      public void deactivate()
      Deactivate tooltip support for the underlying control
    • isRespectDisplayBounds

      public boolean isRespectDisplayBounds()
      Return whether the tooltip respects bounds of the display.
      Returns:
      true if the tooltip respects bounds of the display
    • setRespectDisplayBounds

      public void setRespectDisplayBounds(boolean respectDisplayBounds)
      Set to false if display bounds should not be respected or to true if the tooltip is should repositioned to not overlap the display bounds.

      Default is true

      Parameters:
      respectDisplayBounds - false if tooltip is allowed to overlap display bounds
    • isRespectMonitorBounds

      public boolean isRespectMonitorBounds()
      Return whether the tooltip respects bounds of the monitor.
      Returns:
      true if tooltip respects the bounds of the monitor
    • setRespectMonitorBounds

      public void setRespectMonitorBounds(boolean respectMonitorBounds)
      Set to false if monitor bounds should not be respected or to true if the tooltip is should repositioned to not overlap the monitors bounds. The monitor the tooltip belongs to is the same is control's monitor the tooltip is shown for.

      Default is true

      Parameters:
      respectMonitorBounds - false if tooltip is allowed to overlap monitor bounds
    • shouldCreateToolTip

      protected boolean shouldCreateToolTip(Event event)
      Should the tooltip displayed because of the given event.

      Subclasses may overwrite this to get custom behavior

      Parameters:
      event - the event
      Returns:
      true if tooltip should be displayed
    • getToolTipArea

      protected Object getToolTipArea(Event event)
      This method is called to check for which area the tooltip is created/hidden for. In case of NO_RECREATE this is used to decide if the tooltip is hidden recreated. By the default it is the widget the tooltip is created for but could be any object. To decide if the area changed the Object.equals(Object) method is used.
      Parameters:
      event - the event
      Returns:
      the area responsible for the tooltip creation or null this could be any object describing the area (e.g. the Control onto which the tooltip is bound to, a part of this area e.g. for ColumnViewer this could be a ViewerCell)
    • show

      public void show(Point location)
      Start up the tooltip programmatically
      Parameters:
      location - the location relative to the control the tooltip is shown
    • getLocation

      public Point getLocation(Point tipSize, Event event)
      Get the display relative location where the tooltip is displayed. Subclasses may overwrite to implement custom positioning.
      Parameters:
      tipSize - the size of the tooltip to be shown
      event - the event triggered showing the tooltip
      Returns:
      the absolute position on the display
    • createToolTipContentArea

      protected abstract Composite createToolTipContentArea(Event event, Composite parent)
      Creates the content area of the the tooltip.
      Parameters:
      event - the event that triggered the activation of the tooltip
      parent - the parent of the content area
      Returns:
      the content area created
    • afterHideToolTip

      protected void afterHideToolTip(Event event)
      This method is called after a tooltip is hidden.

      Subclasses may override to clean up requested system resources

      Parameters:
      event - event triggered the hiding action (may be null if event wasn't triggered by user actions directly)
    • setHideDelay

      public void setHideDelay(int hideDelay)
      Set the hide delay.
      Parameters:
      hideDelay - the delay before the tooltip is hidden. If 0 the tooltip is shown until user moves to other item
    • setPopupDelay

      public void setPopupDelay(int popupDelay)
      Set the popup delay.
      Parameters:
      popupDelay - the delay before the tooltip is shown to the user. If 0 the tooltip is shown immediately
    • isHideOnMouseDown

      public boolean isHideOnMouseDown()
      Return if hiding on mouse down is set.
      Returns:
      true if hiding on mouse down in the tool tip is on
    • setHideOnMouseDown

      public void setHideOnMouseDown(boolean hideOnMouseDown)
      If you don't want the tool tip to be hidden when the user clicks inside the tool tip set this to false. You maybe also need to hide the tool tip yourself depending on what you do after clicking in the tooltip (e.g. if you open a new Shell)
      Parameters:
      hideOnMouseDown - flag to indicate of tooltip is hidden automatically on mouse down inside the tool tip
    • hide

      public void hide()
      Hide the currently active tool tip