Package org.eclipse.jface.window
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 int
NO_RECREATE
Don't recreate the tooltip as long the mouse doesn't leave the area triggering the tooltip creationstatic int
RECREATE
Recreate the tooltip on every mouse move
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
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()
Deactivate tooltip support for the underlying controlObject
getData(String key)
Get the data restored under the keyPoint
getLocation(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
isHideOnMouseDown()
Return if hiding on mouse down is set.boolean
isRespectDisplayBounds()
Return whether the tooltip respects bounds of the display.boolean
isRespectMonitorBounds()
Return whether the tooltip respects bounds of the monitor.void
setData(String key, Object value)
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
setShift(Point p)
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
show(Point location)
Start up the tooltip programmatically
-
-
-
Field Detail
-
RECREATE
public static final int RECREATE
Recreate the tooltip on every mouse move- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
-
Constructor Detail
-
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 boundstyle
- style passed to control tooltip behaviormanualActivation
-true
if the activation is done manually usingshow(Point)
- See Also:
RECREATE
,NO_RECREATE
-
-
Method Detail
-
setData
public void setData(String key, Object value)
Restore arbitrary data under the given key- Parameters:
key
- the keyvalue
- 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 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
-
-
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
-
-
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 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
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 shownevent
- 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 tooltipparent
- 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 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
-
-