@Override public WidgetAction.State keyReleased(Widget widget, WidgetAction.WidgetKeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_CONTROL) { switch (getActiveTool()) { case ON_AXIS_MOVE_TOOL: setActiveTool(FREE_MOVE_TOOL); break; case SelectionWrapperWidget.ROTATE_DISCREET_TOOL: setActiveTool(SelectionWrapperWidget.TRANSFORM_TOOL); break; } } else if (event.getKeyCode() == KeyEvent.VK_SHIFT) { if (getActiveTool().equals(SelectionWrapperWidget.RESIZE_FROM_CENTER_TOOL)) { setActiveTool(SelectionWrapperWidget.TRANSFORM_TOOL); } } return WidgetAction.State.REJECTED; }
/** * TODO : Make it undoable? * * @param widget * @param event * @return */ @Override public WidgetAction.State keyPressed(Widget widget, WidgetAction.WidgetKeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_UP) { for (Object o : scene.getSelectedObjects()) { if (o instanceof SubLayoutLayer) { SubLayoutLayer sll = (SubLayoutLayer) o; sll.setY(sll.getY() - 1); } } return WidgetAction.State .CONSUMED; // set it as consumed, so it won't bubble to trigger scrolling } else if (event.getKeyCode() == KeyEvent.VK_DOWN) { for (Object o : scene.getSelectedObjects()) { if (o instanceof SubLayoutLayer) { SubLayoutLayer sll = (SubLayoutLayer) o; sll.setY(sll.getY() + 1); } } return WidgetAction.State .CONSUMED; // set it as consumed, so it won't bubble to trigger scrolling } else if (event.getKeyCode() == KeyEvent.VK_RIGHT) { for (Object o : scene.getSelectedObjects()) { if (o instanceof SubLayoutLayer) { SubLayoutLayer sll = (SubLayoutLayer) o; sll.setX(sll.getX() + 1); } } return WidgetAction.State .CONSUMED; // set it as consumed, so it won't bubble to trigger scrolling } else if (event.getKeyCode() == KeyEvent.VK_LEFT) { for (Object o : scene.getSelectedObjects()) { if (o instanceof SubLayoutLayer) { SubLayoutLayer sll = (SubLayoutLayer) o; sll.setX(sll.getX() - 1); } } return WidgetAction.State .CONSUMED; // set it as consumed, so it won't bubble to trigger scrolling } return super.keyPressed(widget, event); }