Hello,
I need to implement mouse based panning support to my JGoView (the ability to drag the canvas around). This seems like a fairly common application feature— does support for this exist in JGo, or in any example code?
-Justin
Hello,
I need to implement mouse based panning support to my JGoView (the ability to drag the canvas around). This seems like a fairly common application feature— does support for this exist in JGo, or in any example code?
-Justin
Thanks-- this works great. I added some code to trigger the panning mode with the shift key and change the cursor:
@Override
public void keyPressed(KeyEvent evt) {
if (evt.isShiftDown()) {
if (getState() != MouseStatePanning) {
setState(MouseStatePanning);
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
}
}
super.keyPressed(evt);
}
@Override
public void keyReleased(KeyEvent evt) {
if (!evt.isShiftDown()) {
if (getState() == MouseStatePanning) {
setState(MouseStateNone);
setCursor(getDefaultCursor());
}
}
super.keyReleased(evt);
}
However, during the actual dragging the cursor changes temporarily to the selection cursor. I’m having trouble determining what code in JGoView.java is causing this cursor change, as setCursor / setCursorType is only called in a few places…
Perhaps you need to call JGoView.setDefaultCursor.
Did anyone ever get a fix for this?
The cursor is being changed by the drag/drop mechanism. You can avoid that by overriding JGoView.initializeDragDropHandling() as follows:
Thanks, Scott.