use of edu.mit.blocks.workspace.BlockCanvas.Canvas in project openblocks by mikaelhg.
the class FocusTraversalManager method grabFocus.
// /////////////////
// MOUSE METHODS //
// /////////////////
/**
* Action: removes the focus current focused block
* and places new focus on e.getSource
* @requires e != null
* @modifies this.blockFocusOwner && e.getSource
* @effects removes focus from this.blockFocusOwner
* adds focus to e.getSource iff e.getSource
* is instance of BlockCanvas and RenderableBlock
*/
private void grabFocus(MouseEvent e) {
// System.out.println("FocusManager: Mouse Event at ("+ e.getX()+", "+e.getY()+") on "+e.getSource());
if (e.getSource() instanceof Canvas) {
// get canvas point
Point canvasPoint = e.getPoint();
/* SwingUtilities.convertPoint(
(BlockCanvas)e.getSource(),
e.getPoint(),
((BlockCanvas)e.getSource()).getCanvas());*/
setFocus(canvasPoint, Block.NULL);
((Canvas) e.getSource()).grabFocus();
} else if (e.getSource() instanceof RenderableBlock) {
setFocus(((RenderableBlock) e.getSource()).getBlockID());
((RenderableBlock) e.getSource()).grabFocus();
}
}
Aggregations