X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FGrabNDrag.java;h=dc2aa84e6d9480ebc09d0650af1531f3decf5a36;hp=5e5fdd5297b1930955c217f883ae7d1102b08087;hb=af678be97e419a1167a0630f28bcaba82d67929b;hpb=0a6c76fc0525d6588a1d88127f0085f13a02f1af diff --git a/altosuilib/GrabNDrag.java b/altosuilib/GrabNDrag.java index 5e5fdd52..dc2aa84e 100644 --- a/altosuilib/GrabNDrag.java +++ b/altosuilib/GrabNDrag.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_2; +package org.altusmetrum.altosuilib_13; import java.awt.*; import java.awt.event.*; @@ -33,16 +34,23 @@ class GrabNDrag extends MouseInputAdapter { scroll.setAutoscrolls(true); } + public static boolean grab_n_drag(MouseEvent e) { + return e.getModifiers() == InputEvent.BUTTON1_MASK; + } + public void mousePressed(MouseEvent e) { - startPt.setLocation(e.getPoint()); + if (grab_n_drag(e)) + startPt.setLocation(e.getPoint()); } public void mouseDragged(MouseEvent e) { - int xd = e.getX() - startPt.x; - int yd = e.getY() - startPt.y; + if (grab_n_drag(e)) { + int xd = e.getX() - startPt.x; + int yd = e.getY() - startPt.y; - Rectangle r = scroll.getVisibleRect(); - r.x -= xd; - r.y -= yd; - scroll.scrollRectToVisible(r); + Rectangle r = scroll.getVisibleRect(); + r.x -= xd; + r.y -= yd; + scroll.scrollRectToVisible(r); + } } }