From 97cddd5493a69e176256e10686f5af1951aa3191 Mon Sep 17 00:00:00 2001 From: ray Date: Thu, 17 Feb 2005 21:36:19 +0000 Subject: [PATCH] Allow flexibility about which button is used for dragging. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1592 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/swing/ScrollBox.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/swing/ScrollBox.java b/projects/samskivert/src/java/com/samskivert/swing/ScrollBox.java index c8d1c8d6..fbf0f564 100644 --- a/projects/samskivert/src/java/com/samskivert/swing/ScrollBox.java +++ b/projects/samskivert/src/java/com/samskivert/swing/ScrollBox.java @@ -133,6 +133,14 @@ public class ScrollBox extends JPanel _box.height = (int) Math.round(_vert.getExtent() * _vFactor); } + /** + * Return true if the specified button is ok for dragging the box around. + */ + protected boolean isActiveButton (MouseEvent e) + { + return e.getButton() == MouseEvent.BUTTON1; + } + /** The bounds that we observe / modify. */ protected BoundedRangeModel _horz, _vert; @@ -150,7 +158,7 @@ public class ScrollBox extends JPanel // documentation inherited public void mousePressed (MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON1) { + if (isActiveButton(e)) { setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); Point p = e.getPoint(); if (_box.contains(p)) { @@ -180,7 +188,7 @@ public class ScrollBox extends JPanel // documentation inherited public void mouseReleased (MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON1) { + if (isActiveButton(e)) { setCursor(null); _lastPoint = null; }