Skip to content

Commit

Permalink
fix(Manipulators): Add support for alt modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Dec 1, 2017
1 parent a0400d4 commit 57e7ae5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Sources/Interaction/Manipulators/CameraManipulator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const DEFAULT_VALUES = {
button: 1,
shift: false,
control: false,
alt: false,

center: [0, 0, 0],
rotationFactor: 1,
Expand All @@ -54,6 +55,7 @@ export function extend(publicAPI, model, initialValues = {}) {
'button',
'shift',
'control',
'alt',
'rotationFactor',
]);

Expand Down
15 changes: 8 additions & 7 deletions Sources/Interaction/Style/InteractorStyleManipulator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,28 +142,28 @@ function vtkInteractorStyleManipulator(publicAPI, model) {

//-------------------------------------------------------------------------
publicAPI.handleLeftButtonPress = () => {
publicAPI.onButtonDown(1, model.interactor.getShiftKey(), model.interactor.getControlKey());
publicAPI.onButtonDown(1, model.interactor.getShiftKey(), model.interactor.getControlKey(), model.interactor.getAltKey());
};

//-------------------------------------------------------------------------
publicAPI.handleMiddleButtonPress = () => {
publicAPI.onButtonDown(2, model.interactor.getShiftKey(), model.interactor.getControlKey());
publicAPI.onButtonDown(2, model.interactor.getShiftKey(), model.interactor.getControlKey(), model.interactor.getAltKey());
};

//-------------------------------------------------------------------------
publicAPI.handleRightButtonPress = () => {
publicAPI.onButtonDown(3, model.interactor.getShiftKey(), model.interactor.getControlKey());
publicAPI.onButtonDown(3, model.interactor.getShiftKey(), model.interactor.getControlKey(), model.interactor.getAltKey());
};

//-------------------------------------------------------------------------
publicAPI.onButtonDown = (button, shift, control) => {
publicAPI.onButtonDown = (button, shift, control, alt) => {
// Must not be processing an interaction to start another.
if (model.currentManipulator) {
return;
}

// Look for a matching camera interactor.
model.currentManipulator = publicAPI.findManipulator(button, shift, control);
model.currentManipulator = publicAPI.findManipulator(button, shift, control, alt);
if (model.currentManipulator) {
publicAPI.invokeStartInteractionEvent({ type: 'StartInteractionEvent' });
model.currentManipulator.setCenter(model.centerOfRotation);
Expand All @@ -177,14 +177,15 @@ function vtkInteractorStyleManipulator(publicAPI, model) {
};

//-------------------------------------------------------------------------
publicAPI.findManipulator = (button, shift, control) => {
publicAPI.findManipulator = (button, shift, control, alt) => {
// Look for a matching camera manipulator
let manipulator = null;
model.cameraManipulators.forEach((manip) => {
if (manip
&& manip.getButton() === button
&& manip.getShift() === shift
&& manip.getControl() === control) {
&& manip.getControl() === control
&& manip.getAlt() === alt) {
manipulator = manip;
}
});
Expand Down

0 comments on commit 57e7ae5

Please sign in to comment.