ListModel: tooltip/popup interactions
authorNiki Roo <niki@nikiroo.be>
Fri, 1 May 2020 10:05:31 +0000 (12:05 +0200)
committerNiki Roo <niki@nikiroo.be>
Fri, 1 May 2020 10:05:31 +0000 (12:05 +0200)
src/be/nikiroo/utils/ui/ListModel.java

index 3029f61a04c43411da2400f5cf6fb75374dc1a81..7103dbac9a911203d92a1677795f481e8d9d07b2 100644 (file)
@@ -275,7 +275,7 @@ public class ListModel<T> extends DefaultListModel6<T> {
                                        hoveredIndex = index;
                                        fireElementChanged(oldIndex);
                                        fireElementChanged(index);
-                                       
+
                                        Window oldTooltip = tooltip;
                                        tooltip = null;
                                        if (oldTooltip != null) {
@@ -298,6 +298,11 @@ public class ListModel<T> extends DefaultListModel6<T> {
                                                                                        return;
                                                                                }
 
+                                                                               if (popup != null
+                                                                                               && popup.isShowing()) {
+                                                                                       return;
+                                                                               }
+
                                                                                tooltip = newTooltip(index, me);
                                                                        }
                                                                });
@@ -340,6 +345,12 @@ public class ListModel<T> extends DefaultListModel6<T> {
                                                                list.locationToIndex(e.getPoint()));
                                        }
 
+                                       Window oldTooltip = tooltip;
+                                       tooltip = null;
+                                       if (oldTooltip != null) {
+                                               oldTooltip.setVisible(false);
+                                       }
+
                                        popup.show(list, e.getX(), e.getY());
                                }
                        }