Moved component-level cursor handling into methods.
Fix: don't copy down parental cursors to children when we drag over them. git-svn-id: https://samskivert.googlecode.com/svn/trunk@824 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DnDManager.java,v 1.6 2002/09/06 00:07:40 ray Exp $
|
// $Id: DnDManager.java,v 1.7 2002/09/06 00:26:10 ray Exp $
|
||||||
|
|
||||||
package com.samskivert.swing.dnd;
|
package com.samskivert.swing.dnd;
|
||||||
|
|
||||||
@@ -137,11 +137,31 @@ public class DnDManager
|
|||||||
_topCursor = _topComp.getCursor();
|
_topCursor = _topComp.getCursor();
|
||||||
_topComp.setCursor(_curCursor);
|
_topComp.setCursor(_curCursor);
|
||||||
|
|
||||||
// and see if we need to also set the cursor in the current component
|
setComponentCursor(_sourceComp);
|
||||||
if (_sourceComp.getCursor() != _curCursor) {
|
}
|
||||||
_lastComp = _sourceComp;
|
|
||||||
_oldCursor = _lastComp.getCursor();
|
/**
|
||||||
_lastComp.setCursor(_curCursor);
|
* Check to see if we need to do component-level cursor setting and take
|
||||||
|
* care of it if needed.
|
||||||
|
*/
|
||||||
|
protected void setComponentCursor (Component comp)
|
||||||
|
{
|
||||||
|
Cursor c = comp.getCursor();
|
||||||
|
if (c != _curCursor) {
|
||||||
|
_lastComp = comp;
|
||||||
|
_oldCursor = comp.isCursorSet() ? c : null;
|
||||||
|
comp.setCursor(_curCursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear out the component-level cursor.
|
||||||
|
*/
|
||||||
|
protected void clearComponentCursor ()
|
||||||
|
{
|
||||||
|
if (_lastComp != null) {
|
||||||
|
_lastComp.setCursor(_oldCursor);
|
||||||
|
_lastComp = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,20 +192,13 @@ public class DnDManager
|
|||||||
_lastTarget = findAppropriateTarget(newcomp);
|
_lastTarget = findAppropriateTarget(newcomp);
|
||||||
Cursor newcursor = _cursors[(_lastTarget == null) ? 1 : 0];
|
Cursor newcursor = _cursors[(_lastTarget == null) ? 1 : 0];
|
||||||
|
|
||||||
|
// see if the current cursor changed.
|
||||||
if (newcursor != _curCursor) {
|
if (newcursor != _curCursor) {
|
||||||
// change the top-level feedback cursor.
|
|
||||||
_topComp.setCursor(_curCursor = newcursor);
|
_topComp.setCursor(_curCursor = newcursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// see if need to override the cursor in the component
|
// and check the cursor at the component level
|
||||||
if (newcomp.getCursor() != _curCursor) {
|
setComponentCursor(newcomp);
|
||||||
_lastComp = newcomp;
|
|
||||||
_oldCursor = _lastComp.getCursor();
|
|
||||||
_lastComp.setCursor(_curCursor);
|
|
||||||
} else {
|
|
||||||
// we don't
|
|
||||||
_lastComp = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,11 +206,7 @@ public class DnDManager
|
|||||||
*/
|
*/
|
||||||
protected void mouseExited (MouseEvent event)
|
protected void mouseExited (MouseEvent event)
|
||||||
{
|
{
|
||||||
// reset the component's custom cursor if it had one
|
clearComponentCursor();
|
||||||
if (_lastComp != null) {
|
|
||||||
_lastComp.setCursor(_oldCursor);
|
|
||||||
_lastComp = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// and if we were over a target, let the target know that we left
|
// and if we were over a target, let the target know that we left
|
||||||
if (_lastTarget != null) {
|
if (_lastTarget != null) {
|
||||||
@@ -215,9 +224,7 @@ public class DnDManager
|
|||||||
Toolkit.getDefaultToolkit().removeAWTEventListener(this);
|
Toolkit.getDefaultToolkit().removeAWTEventListener(this);
|
||||||
|
|
||||||
// reset cursors
|
// reset cursors
|
||||||
if (_lastComp != null) {
|
clearComponentCursor();
|
||||||
_lastComp.setCursor(_oldCursor);
|
|
||||||
}
|
|
||||||
_topComp.setCursor(_topCursor);
|
_topComp.setCursor(_topCursor);
|
||||||
|
|
||||||
// the event.getComponent() will be the source component here (huh..)
|
// the event.getComponent() will be the source component here (huh..)
|
||||||
|
|||||||
Reference in New Issue
Block a user