# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: D:\source_code\JavaFX source code\OpenJFX_8u_dev
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: modules/controls/src/main/java/javafx/scene/control/Tooltip.java
--- modules/controls/src/main/java/javafx/scene/control/Tooltip.java
+++ modules/controls/src/main/java/javafx/scene/control/Tooltip.java
@@ -107,6 +107,17 @@
* Button button = new Button("Hover Over Me");
* button.setTooltip(new Tooltip("Tooltip for Button"));
*
+ *
+ *
The duration that the tooltips are shown, hide on over and hide on exit are
+ * configurable.
+ *
+ * Tooltip tooltip = new Tooltip();
+ * tooltip.setShowDelay(new Duration(200));
+ * tooltip.setShowDurationOnOver(new Duration(10000));
+ * tooltip.setShowDurationOnExit(new Duration(100));
+ *
+ * Default timing values are: Show delay is 1 second, show duration on over is 5 second and
+ * show duration on exit is 200 milliseconds.
* @since JavaFX 2.0
*/
@IDProperty("id")
@@ -122,9 +133,12 @@
private static int TOOLTIP_XOFFSET = 10;
private static int TOOLTIP_YOFFSET = 7;
- private static TooltipBehavior BEHAVIOR = new TooltipBehavior(
- new Duration(1000), new Duration(5000), new Duration(200), false);
+ private static final Duration showDelay = new Duration(1000);
+ private static final Duration showDurationOnOver = new Duration(5000);
+ private static final Duration showDurationOnExit = new Duration(200);
+ private static TooltipBehavior BEHAVIOR = new TooltipBehavior(false);
+
/**
* Associates the given {@link Tooltip} with the given {@link Node}. The tooltip
* can then behave similar to when it is set on any {@link Control}. A single
@@ -306,6 +320,51 @@
};
/**
+ * The duration since tooltips are activated to be shown.
+ */
+ public final void setShowDelay(Duration showDelay) {
+ showDelayProperty.set(showDelay);
+ }
+ public final Duration getShowDelay() {
+ return showDelayProperty.get();
+ }
+ public final ObjectProperty showDelayProperty() {
+ return showDelayProperty;
+ }
+ private final ObjectProperty showDelayProperty
+ = new SimpleObjectProperty<>(showDelay);
+
+ /**
+ * The duration since mouse stops moving to hide the tooltip.
+ */
+ public final void setShowDurationOnOver(Duration showDelay) {
+ showDurationOnOverProperty.set(showDelay);
+ }
+ public final Duration getShowDurationOnOver() {
+ return showDurationOnOverProperty.get();
+ }
+ public final ObjectProperty showDurationOnOverProperty() {
+ return showDurationOnOverProperty;
+ }
+ private final ObjectProperty showDurationOnOverProperty
+ = new SimpleObjectProperty<>(showDurationOnOver);
+
+ /**
+ * The duration since mouse exits to hide the tooltip.
+ */
+ public final void setShowDurationOnExit(Duration showDelay) {
+ showDurationOnExitProperty.set(showDelay);
+ }
+ public final Duration getShowDurationOnExit() {
+ return showDurationOnExitProperty.get();
+ }
+ public final ObjectProperty showDurationOnExitProperty() {
+ return showDurationOnExitProperty;
+ }
+ private final ObjectProperty showDurationOnExitProperty
+ = new SimpleObjectProperty<>(showDurationOnExit);
+
+ /**
* An optional icon for the Tooltip. This can be positioned relative to the
* text by using the {@link #contentDisplayProperty() content display}
* property.
@@ -670,11 +729,11 @@
* is activated as soon as a mouse move occurs over the target node. When it
* becomes activated, we start off the ACTIVATION_TIMER. If the
* ACTIVATION_TIMER expires before another mouse event occurs, then we will
- * show the popup. This timer typically lasts about 1 second.
+ * show the popup. This timer by default lasts about 1 second.
*
* Once visible, we reset the ACTIVATION_TIMER and start the HIDE_TIMER.
* This second timer will allow the tooltip to remain visible for some time
- * period (such as 5 seconds). If the mouse hasn't moved, and the HIDE_TIMER
+ * period (by default 5 seconds). If the mouse hasn't moved, and the HIDE_TIMER
* expires, then the tooltip is hidden and the tooltip is no longer
* activated.
*
@@ -682,8 +741,8 @@
* same rules apply as above.
*
* If a mouse exit event occurs while the HIDE_TIMER is ticking, we reset
- * the HIDE_TIMER. Thus, the tooltip disappears after 5 seconds from the
- * last mouse move.
+ * the HIDE_TIMER. Thus, the tooltip disappears, by default, after 5 seconds
+ * from the last mouse move.
*
* If some other mouse event occurs while the HIDE_TIMER is running, other
* than mouse move or mouse enter/exit (such as a click), then the tooltip
@@ -691,7 +750,7 @@
*
* If a mouse exit occurs while the HIDE_TIMER is running, we stop the
* HIDE_TIMER and start the LEFT_TIMER, and immediately hide the tooltip.
- * This timer is very short, maybe about a 1/2 second. If the mouse enters a
+ * This timer is very short, by default, 1/2 second. If the mouse enters a
* new node which also has a tooltip before LEFT_TIMER expires, then the
* second tooltip is activated and shown immediately (the ACTIVATION_TIMER
* having been bypassed), and the HIDE_TIMER is started. If the LEFT_TIMER
@@ -730,10 +789,9 @@
private boolean hideOnExit;
- TooltipBehavior(Duration openDelay, Duration visibleDuration, Duration closeDelay, final boolean hideOnExit) {
+ TooltipBehavior(final boolean hideOnExit) {
this.hideOnExit = hideOnExit;
- activationTimer.getKeyFrames().add(new KeyFrame(openDelay));
activationTimer.setOnFinished(event -> {
// Show the currently activated tooltip and start the
// HIDE_TIMER.
@@ -785,6 +843,7 @@
visibleTooltip = activatedTooltip;
hoveredNode = null;
+ hideTimer.getKeyFrames().setAll(new KeyFrame(activatedTooltip.getShowDurationOnOver()));
hideTimer.playFromStart();
}
@@ -795,7 +854,6 @@
activatedTooltip = null;
});
- hideTimer.getKeyFrames().add(new KeyFrame(visibleDuration));
hideTimer.setOnFinished(event -> {
// Hide the currently visible tooltip.
assert visibleTooltip != null;
@@ -804,7 +862,6 @@
hoveredNode = null;
});
- leftTimer.getKeyFrames().add(new KeyFrame(closeDelay));
leftTimer.setOnFinished(event -> {
if (!hideOnExit) {
// Hide the currently visible tooltip.
@@ -860,6 +917,7 @@
t.show(owner, event.getScreenX()+TOOLTIP_XOFFSET,
event.getScreenY()+TOOLTIP_YOFFSET);
leftTimer.stop();
+ hideTimer.getKeyFrames().setAll(new KeyFrame(t.getShowDurationOnOver()));
hideTimer.playFromStart();
} else {
// Start / restart the timer and make sure the tooltip
@@ -867,6 +925,7 @@
t.setActivated(true);
activatedTooltip = t;
activationTimer.stop();
+ activationTimer.getKeyFrames().setAll(new KeyFrame(t.getShowDelay()));
activationTimer.playFromStart();
}
}
@@ -888,8 +947,13 @@
assert visibleTooltip != null;
hideTimer.stop();
if (hideOnExit) visibleTooltip.hide();
+ Node source = (Node) event.getSource();
+ Tooltip t = (Tooltip) source.getProperties().get(TOOLTIP_PROP_KEY);
+ if (t != null) {
+ leftTimer.getKeyFrames().setAll(new KeyFrame(t.getShowDurationOnExit()));
leftTimer.playFromStart();
}
+ }
hoveredNode = null;
activatedTooltip = null;