public abstract class ToolTip extends Object
Modifier and Type | Field and Description |
---|---|
static int |
NO_RECREATE
Don't recreate the tooltip as long the mouse doesn't leave the area
triggering the tooltip creation
|
static int |
RECREATE
Recreate the tooltip on every mouse move
|
Constructor and Description |
---|
ToolTip(Control control)
Create new instance which add TooltipSupport to the widget
|
ToolTip(Control control,
int style,
boolean manualActivation) |
Modifier and Type | Method and Description |
---|---|
void |
activate()
Activate tooltip support for this control
|
protected 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 control
|
Object |
getData(String key)
Get the data restored under the key
|
Point |
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 tip
|
boolean |
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 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 |
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
|
public static final int RECREATE
public static final int NO_RECREATE
public ToolTip(Control control)
control
- the control on whose action the tooltip is shownpublic ToolTip(Control control, int style, boolean manualActivation)
control
- the control to which the tooltip is boundstyle
- style passed to control tooltip behaviormanualActivation
- true
if the activation is done manually using
show(Point)
RECREATE
,
NO_RECREATE
public void setData(String key, Object value)
key
- the keyvalue
- the valuepublic Object getData(String key)
key
- the keynull
if no entry is restored under the keypublic void setShift(Point p)
By default the tooltip is shifted 3 pixels to the right.
p
- the new shiftpublic void activate()
public void deactivate()
public boolean isRespectDisplayBounds()
true
if the tooltip respects bounds of the displaypublic void setRespectDisplayBounds(boolean respectDisplayBounds)
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
respectDisplayBounds
- public boolean isRespectMonitorBounds()
true
if tooltip respects the bounds of the monitorpublic void setRespectMonitorBounds(boolean respectMonitorBounds)
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
respectMonitorBounds
- protected boolean shouldCreateToolTip(Event event)
Subclasses may overwrite this to get custom behavior
event
- the eventtrue
if tooltip should be displayedprotected Object getToolTipArea(Event event)
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.
event
- the eventnull
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
)public void show(Point location)
location
- the location relative to the control the tooltip is shownpublic Point getLocation(Point tipSize, Event event)
tipSize
- the size of the tooltip to be shownevent
- the event triggered showing the tooltipprotected abstract Composite createToolTipContentArea(Event event, Composite parent)
event
- the event that triggered the activation of the tooltipparent
- the parent of the content areaprotected void afterHideToolTip(Event event)
Subclasses may override to clean up requested system resources
event
- event triggered the hiding action (may be null
if event wasn't triggered by user actions directly)public void setHideDelay(int hideDelay)
hideDelay
- the delay before the tooltip is hidden. If 0
the tooltip is shown until user moves to other itempublic void setPopupDelay(int popupDelay)
popupDelay
- the delay before the tooltip is shown to the user. If
0
the tooltip is shown immediatelypublic boolean isHideOnMouseDown()
true
if hiding on mouse down in the tool tip is onpublic void setHideOnMouseDown(boolean hideOnMouseDown)
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
)hideOnMouseDown
- flag to indicate of tooltip is hidden automatically on mouse
down inside the tool tippublic void hide()
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.