Bug fixes
[fanfix.git] / src / jexer / TScrollableWindow.java
index ce20df7df9f5d1f9d68cbccaa38345277feea2e7..ae5f50c570e645a78f79d4170a73138e0fe3d41a 100644 (file)
@@ -28,6 +28,7 @@
  */
 package jexer;
 
+import jexer.event.TMouseEvent;
 import jexer.event.TResizeEvent;
 
 /**
@@ -599,4 +600,46 @@ public class TScrollableWindow extends TWindow implements Scrollable {
         }
     }
 
+    /**
+     * Check if a mouse press/release/motion event coordinate is over the
+     * vertical scrollbar.
+     *
+     * @param mouse a mouse-based event
+     * @return whether or not the mouse is on the scrollbar
+     */
+    protected final boolean mouseOnVerticalScroller(final TMouseEvent mouse) {
+        if (vScroller == null) {
+            return false;
+        }
+        if ((mouse.getAbsoluteX() == vScroller.getAbsoluteX())
+            && (mouse.getAbsoluteY() >= vScroller.getAbsoluteY())
+            && (mouse.getAbsoluteY() <  vScroller.getAbsoluteY() +
+                vScroller.getHeight())
+        ) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Check if a mouse press/release/motion event coordinate is over the
+     * horizontal scrollbar.
+     *
+     * @param mouse a mouse-based event
+     * @return whether or not the mouse is on the scrollbar
+     */
+    protected final boolean mouseOnHorizontalScroller(final TMouseEvent mouse) {
+        if (hScroller == null) {
+            return false;
+        }
+        if ((mouse.getAbsoluteY() == hScroller.getAbsoluteY())
+            && (mouse.getAbsoluteX() >= hScroller.getAbsoluteX())
+            && (mouse.getAbsoluteX() <  hScroller.getAbsoluteX() +
+                hScroller.getWidth())
+        ) {
+            return true;
+        }
+        return false;
+    }
+
 }