git://git.nikiroo.be
/
nikiroo-utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
8b2627c
)
ListModel: fix tooltip delay
author
Niki Roo
<niki@nikiroo.be>
Fri, 1 May 2020 09:57:01 +0000
(11:57 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Fri, 1 May 2020 09:57:01 +0000
(11:57 +0200)
ui/ListModel.java
patch
|
blob
|
blame
|
history
diff --git
a/ui/ListModel.java
b/ui/ListModel.java
index cf16d5f0a111e660171102b3efad3bdefe1d6d48..3029f61a04c43411da2400f5cf6fb75374dc1a81 100644
(file)
--- a/
ui/ListModel.java
+++ b/
ui/ListModel.java
@@
-34,6
+34,9
@@
import be.nikiroo.utils.compat.ListCellRenderer6;
public class ListModel<T> extends DefaultListModel6<T> {
private static final long serialVersionUID = 1L;
public class ListModel<T> extends DefaultListModel6<T> {
private static final long serialVersionUID = 1L;
+ /** How long to wait before displaying a tooltip, in milliseconds. */
+ private static final int DELAY_TOOLTIP_MS = 1000;
+
/**
* A filter interface, to check for a condition (note that a Predicate class
* already exists in Java 1.8+, and is compatible with this one if you
/**
* A filter interface, to check for a condition (note that a Predicate class
* already exists in Java 1.8+, and is compatible with this one if you
@@
-254,7
+257,7
@@
public class ListModel<T> extends DefaultListModel6<T> {
list.setModel(this);
list.setModel(this);
- final DelayWorker tooltipWatcher = new DelayWorker(
500
);
+ final DelayWorker tooltipWatcher = new DelayWorker(
DELAY_TOOLTIP_MS
);
if (tooltipCreator != null) {
tooltipWatcher.start();
}
if (tooltipCreator != null) {
tooltipWatcher.start();
}
@@
-272,6
+275,12
@@
public class ListModel<T> extends DefaultListModel6<T> {
hoveredIndex = index;
fireElementChanged(oldIndex);
fireElementChanged(index);
hoveredIndex = index;
fireElementChanged(oldIndex);
fireElementChanged(index);
+
+ Window oldTooltip = tooltip;
+ tooltip = null;
+ if (oldTooltip != null) {
+ oldTooltip.setVisible(false);
+ }
if (ListModel.this.tooltipCreator != null) {
tooltipWatcher.delay("tooltip",
if (ListModel.this.tooltipCreator != null) {
tooltipWatcher.delay("tooltip",
@@
-284,12
+293,6
@@
public class ListModel<T> extends DefaultListModel6<T> {
@Override
protected void done() {
@Override
protected void done() {
- Window oldTooltip = tooltip;
- tooltip = null;
- if (oldTooltip != null) {
- oldTooltip.setVisible(false);
- }
-
if (index < 0
|| index != hoveredIndex) {
return;
if (index < 0
|| index != hoveredIndex) {
return;