Package org.eclipse.jface.window
Class ToolTip
java.lang.Object
org.eclipse.jface.window.ToolTip
- Direct Known Subclasses:
DefaultToolTip
This class gives implementors to provide customized tooltips for any control.
- Since:
- 3.3
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Don't recreate the tooltip as long the mouse doesn't leave the area triggering the tooltip creationstatic final int
Recreate the tooltip on every mouse move -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Activate tooltip support for this controlprotected void
afterHideToolTip
(Event event) This method is called after a tooltip is hidden.protected abstract Composite
createToolTipContentArea
(Event event, Composite parent) Creates the content area of the the tooltip.void
Deactivate tooltip support for the underlying controlGet the data restored under the keygetLocation
(Point tipSize, Event event) Get the display relative location where the tooltip is displayed.protected Object
getToolTipArea
(Event event) This method is called to check for which area the tooltip is created/hidden for.void
hide()
Hide the currently active tool tipboolean
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
Restore arbitrary data under the given keyvoid
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 tofalse
.void
setPopupDelay
(int popupDelay) Set the popup delay.void
setRespectDisplayBounds
(boolean respectDisplayBounds) Set tofalse
if display bounds should not be respected or totrue
if the tooltip is should repositioned to not overlap the display bounds.void
setRespectMonitorBounds
(boolean respectMonitorBounds) Set tofalse
if monitor bounds should not be respected or totrue
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
shouldCreateToolTip
(Event event) Should the tooltip displayed because of the given event.void
Start up the tooltip programmatically
-
Field Details
-
RECREATE
public static final int RECREATERecreate the tooltip on every mouse move- See Also:
-
NO_RECREATE
public static final int NO_RECREATEDon't recreate the tooltip as long the mouse doesn't leave the area triggering the tooltip creation- See Also:
-
-
Constructor Details
-
ToolTip
Create new instance which add TooltipSupport to the widget- Parameters:
control
- the control on whose action the tooltip is shown
-
ToolTip
- Parameters:
control
- the control to which the tooltip is boundstyle
- style passed to control tooltip behaviormanualActivation
-true
if the activation is done manually usingshow(Point)
- See Also:
-
-
Method Details
-
setData
Restore arbitrary data under the given key- Parameters:
key
- the keyvalue
- the value
-
getData
Get the data restored under the key- Parameters:
key
- the key- Returns:
- data or
null
if no entry is restored under the key
-
setShift
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 tofalse
if display bounds should not be respected or totrue
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 tofalse
if monitor bounds should not be respected or totrue
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
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
This method is called to check for which area the tooltip is created/hidden for. In case ofNO_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. theControl
onto which the tooltip is bound to, a part of this area e.g. forColumnViewer
this could be aViewerCell
)
-
show
Start up the tooltip programmatically- Parameters:
location
- the location relative to the control the tooltip is shown
-
getLocation
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 shownevent
- the event triggered showing the tooltip- Returns:
- the absolute position on the display
-
createToolTipContentArea
Creates the content area of the the tooltip.- Parameters:
event
- the event that triggered the activation of the tooltipparent
- the parent of the content area- Returns:
- the content area created
-
afterHideToolTip
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 benull
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. If0
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. If0
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 tofalse
. 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 newShell
)- 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
-