# 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,16 @@
* 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
+ * applied globally.
+ *
+ * Tooltip.setShowDelay(new Duration(200));
+ * Tooltip.setShowDurationOnOver(new Duration(10000));
+ * Tooltip.setShowDurationOnExit(new Duration(100));
+ *
+ * Show delay default value 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 +132,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
@@ -145,6 +158,52 @@
BEHAVIOR.uninstall(node);
}
+
+ /**
+ * The duration since mouse enters to be shown. By default 1 second.
+ */
+ public static void setShowDelay(Duration showDelay) {
+ BEHAVIOR.setShowDelay(showDelay);
+ }
+
+ public static final Duration getShowDelay() {
+ return BEHAVIOR.getShowDelay();
+ }
+
+ public static final ObjectProperty showDelayProperty() {
+ return BEHAVIOR.showDelayProperty();
+ }
+
+ /**
+ * The duration since mouse stops moving to hide the tooltip. By default 5 seconds.
+ */
+ public static final void setShowDurationOnOver(Duration showDelayOnOver) {
+ BEHAVIOR.setShowDurationOnOver(showDelayOnOver);
+ }
+
+ public static final Duration getShowDurationOnOver() {
+ return BEHAVIOR.getShowDurationOnOver();
+ }
+
+ public static final ObjectProperty showDurationOnOverProperty() {
+ return BEHAVIOR.showDurationOnOverProperty();
+ }
+
+ /**
+ * The duration since mouse exits to hide the tooltip. By default 200 milliseconds.
+ */
+ public static final void setShowDurationOnExit(Duration showDelay) {
+ BEHAVIOR.setShowDurationOnExit(showDelay);
+ }
+
+ public static final Duration getShowDurationOnExit() {
+ return BEHAVIOR.getShowDurationOnExit();
+ }
+
+ public static final ObjectProperty showDurationOnExitProperty(){
+ return BEHAVIOR.showDurationOnExitProperty();
+ }
+
/***************************************************************************
* *
* Constructors *
@@ -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,65 @@
private boolean hideOnExit;
- TooltipBehavior(Duration openDelay, Duration visibleDuration, Duration closeDelay, final boolean hideOnExit) {
+ /**
+ * The duration since tooltips are activated to be shown.
+ */
+ private final ObjectProperty showDelayProperty
+ = new SimpleObjectProperty<>(showDelay);
+
+ private final void setShowDelay(Duration showDelay) {
+ showDelayProperty.set(showDelay);
+ }
+
+ private final Duration getShowDelay() {
+ return showDelayProperty.get();
+ }
+
+ private final ObjectProperty showDelayProperty() {
+ return showDelayProperty;
+ }
+
+ /**
+ * The duration since mouse stops moving to hide the tooltip.
+ */
+ private final ObjectProperty showDurationOnOverProperty
+ = new SimpleObjectProperty<>(showDurationOnOver);
+
+ private final void setShowDurationOnOver(Duration showDelay) {
+ showDurationOnOverProperty.set(showDelay);
+ }
+
+ private final Duration getShowDurationOnOver() {
+ return showDurationOnOverProperty.get();
+ }
+
+ private final ObjectProperty showDurationOnOverProperty() {
+ return showDurationOnOverProperty;
+ }
+
+ /**
+ * The duration since mouse exits to hide the tooltip.
+ */
+ private final ObjectProperty showDurationOnExitProperty
+ = new SimpleObjectProperty<>(showDurationOnExit);
+
+ private final void setShowDurationOnExit(Duration showDelay) {
+ showDurationOnExitProperty.set(showDelay);
+ }
+
+ private final Duration getShowDurationOnExit() {
+ return showDurationOnExitProperty.get();
+ }
+
+ private final ObjectProperty showDurationOnExitProperty() {
+ return showDurationOnExitProperty;
+ }
+
+ TooltipBehavior(final boolean hideOnExit) {
this.hideOnExit = hideOnExit;
- activationTimer.getKeyFrames().add(new KeyFrame(openDelay));
+ showDelayProperty.addListener(inv -> updateActivationTimer());
+ activationTimer.getKeyFrames().setAll(new KeyFrame(getShowDelay()));
activationTimer.setOnFinished(event -> {
// Show the currently activated tooltip and start the
// HIDE_TIMER.
@@ -794,8 +908,8 @@
activatedTooltip.setActivated(false);
activatedTooltip = null;
});
-
- hideTimer.getKeyFrames().add(new KeyFrame(visibleDuration));
+ showDurationOnOverProperty.addListener(inv -> updateHideTimer());
+ hideTimer.getKeyFrames().setAll(new KeyFrame(getShowDurationOnOver()));
hideTimer.setOnFinished(event -> {
// Hide the currently visible tooltip.
assert visibleTooltip != null;
@@ -803,8 +917,8 @@
visibleTooltip = null;
hoveredNode = null;
});
-
- leftTimer.getKeyFrames().add(new KeyFrame(closeDelay));
+ showDurationOnExitProperty.addListener(inv -> updateLeftTimer());
+ leftTimer.getKeyFrames().setAll(new KeyFrame(getShowDurationOnExit()));
leftTimer.setOnFinished(event -> {
if (!hideOnExit) {
// Hide the currently visible tooltip.
@@ -816,6 +930,34 @@
});
}
+
+ private final void updateActivationTimer(){
+ boolean restart = activationTimer.getStatus() == Timeline.Status.RUNNING;
+ activationTimer.stop();
+ activationTimer.getKeyFrames().setAll(new KeyFrame(getShowDelay()));
+ if(restart){
+ activationTimer.playFromStart();
+ }
+ }
+
+ private final void updateHideTimer(){
+ boolean restart = hideTimer.getStatus() == Timeline.Status.RUNNING;
+ hideTimer.stop();
+ hideTimer.getKeyFrames().setAll(new KeyFrame(getShowDurationOnOver()));
+ if(restart){
+ hideTimer.playFromStart();
+ }
+ }
+
+ private final void updateLeftTimer(){
+ boolean restart = leftTimer.getStatus() == Timeline.Status.RUNNING;
+ leftTimer.stop();
+ leftTimer.getKeyFrames().setAll(new KeyFrame(getShowDurationOnExit()));
+ if(restart){
+ leftTimer.playFromStart();
+ }
+ }
+
/**
* Registers for mouse move events only. When the mouse is moved, this
* handler will detect it and decide whether to start the ACTIVATION_TIMER