ctrl -> color select (like middle mouse button)

This commit is contained in:
HF 2020-11-30 22:41:51 +01:00
parent 715ba5efaf
commit c263bc72d9

View File

@ -400,11 +400,10 @@ class PixelPlainterControls {
}
const coords = screenToWorld(state, viewport, center);
const clrIndex = renderer.getColorIndexOfPixel(...coords);
if (clrIndex === null) {
return;
}
if (clrIndex !== null) {
store.dispatch(selectColor(clrIndex));
}
}
onAuxClick(event: MouseEvent) {
const { which, clientX, clientY } = event;
@ -440,8 +439,9 @@ class PixelPlainterControls {
return;
}
const { store } = this;
const key = keycode(event);
switch (keycode(event)) {
switch (key) {
case 'up':
case 'w':
store.dispatch(moveNorth());
@ -466,13 +466,21 @@ class PixelPlainterControls {
case 'q':
store.dispatch(zoomOut());
break;
case 'ctrl':
case 'shift': {
const state = store.getState();
const { hover } = state.gui;
if (hover) {
if (key === 'ctrl') {
const clrIndex = this.renderer.getColorIndexOfPixel(...hover);
if (clrIndex !== null) {
store.dispatch(selectColor(clrIndex));
}
} else {
this.holdPainting = true;
PixelPlainterControls.placePixel(store, this.renderer, hover);
}
}
break;
}
default: