Skip to content

Commit

Permalink
Make default hide delay for tooltip configurable (#364)
Browse files Browse the repository at this point in the history
The hide delay for tooltips in Draw2d is currently fixed to 5 seconds.
The value can only be changed for a speific `ToolTipHelper`, which in
turn is tied to a specific control. There is option to configure this
delay globally.

With this change, the default value for the hide delay can globally be
changed on the `ToolTipHelper` class, such that subsequent tooltip
creations will use this value as default.
  • Loading branch information
HeikoKlare committed Jan 19, 2024
1 parent b589067 commit e9839e7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion org.eclipse.draw2d/src/org/eclipse/draw2d/ToolTipHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
*/
public class ToolTipHelper extends PopUpHelper {

private static int defaultHideDelay = 5000;

private Timer timer;
private IFigure currentTipSource;
private int hideDelay = 5000;
private int hideDelay;

/**
* Constructs a ToolTipHelper to be associated with Control <i>c</i>.
Expand All @@ -46,6 +48,7 @@ public ToolTipHelper(org.eclipse.swt.widgets.Control c) {
super(c, SWT.TOOL | SWT.ON_TOP);
getShell().setBackground(ColorConstants.tooltipBackground);
getShell().setForeground(ColorConstants.tooltipForeground);
hideDelay = defaultHideDelay;
}

/*
Expand Down Expand Up @@ -82,6 +85,18 @@ public void setHideDelay(int hideDelay) {
this.hideDelay = hideDelay;
}

/**
* Sets the default tooltip hide delay, which is the number in ms after which
* the tooltip will disappear again if not overwritten using
* {@link #setHideDelay(int)}.
*
* @param defaultHideDelay the delay in ms after which the tooltip is hidden
* @since 3.15
*/
public static void setDefaultHideDelay(int defaultHideDelay) {
ToolTipHelper.defaultHideDelay = defaultHideDelay;
}

/**
* Sets the LightWeightSystem's contents to the passed tooltip, and displays the
* tip. The tip will be displayed only if the tip source is different than the
Expand Down

0 comments on commit e9839e7

Please sign in to comment.