Add missing mobile modifier support

Improves multi-selection on mobile
Closes #847
This commit is contained in:
JannisX11 2021-08-03 11:04:40 +02:00
parent 1344841417
commit e65c260823
11 changed files with 39 additions and 39 deletions

View File

@ -280,13 +280,13 @@ class Keyframe {
Timeline.dragging_keyframes = false
return this;
}
if (!event || (!event.shiftKey && !event.ctrlOrCmd)) {
if (!event || (!event.shiftKey && !event.ctrlOrCmd && !Pressing.overrides.ctrl && !Pressing.overrides.shift)) {
Timeline.selected.forEach(function(kf) {
kf.selected = false
})
Timeline.selected.empty()
}
if (event && event.shiftKey && Timeline.selected.length) {
if (event && (event.shiftKey || Pressing.overrides.shift) && Timeline.selected.length) {
var last = Timeline.selected[Timeline.selected.length-1]
if (last && last.channel === scope.channel && last.animator == scope.animator) {
Timeline.keyframes.forEach((kf) => {
@ -491,8 +491,8 @@ BARS.defineActions(function() {
if (Toolbox.selected.id == 'rotate_tool' && animator.channels.includes('rotation')) channel = 'rotation';
if (Toolbox.selected.id == 'move_tool' && animator.channels.includes('position')) channel = 'position';
if (Toolbox.selected.id == 'resize_tool' && animator.channels.includes('scale')) channel = 'scale';
animator.createKeyframe((event && event.shiftKey) ? {} : null, Timeline.time, channel, true);
if (event && event.shiftKey) {
animator.createKeyframe((event && (event.shiftKey || Pressing.overrides.shift)) ? {} : null, Timeline.time, channel, true);
if (event && (event.shiftKey || Pressing.overrides.shift)) {
Animator.preview();
}
}

View File

@ -77,7 +77,7 @@ const Timeline = {
e.clientX - R.panel_offset[0],
e.clientY - R.panel_offset[1],
]
if (e.shiftKey) {
if (e.shiftKey || Pressing.overrides.shift) {
Timeline.selector.selected_before = Timeline.selected.slice();
}
R.selecting = true;
@ -268,7 +268,7 @@ const Timeline = {
let offset = e.clientX - $('#timeline_time').offset().left;
let time = Math.clamp(offset / Timeline.vue._data.size, 0, Infinity);
if (!e.ctrlOrCmd) time = Timeline.snapTime(time);
if (!e && !Pressing.overrides.ctrl) time = Timeline.snapTime(time);
Timeline.setTime(time);
Animator.preview();
}
@ -279,7 +279,7 @@ const Timeline = {
convertTouchEvent(e);
let offset = e.clientX - $('#timeline_time').offset().left;
let time = Math.clamp(offset / Timeline.vue._data.size, 0, Infinity);
if (!e.ctrlOrCmd) time = Timeline.snapTime(time);
if (!e.ctrlOrCmd && !Pressing.overrides.ctrl) time = Timeline.snapTime(time);
if (Timeline.time != time) {
Timeline.setTime(time)
Animator.preview()
@ -750,10 +750,10 @@ onVueSetup(function() {
dragging_restriction;
originalValue;
previousValue = 0;
time_stretching = !Timeline.vue.graph_editor_open && e1.ctrlOrCmd && Timeline.selected.length > 1;
time_stretching = !Timeline.vue.graph_editor_open && (e1.ctrlOrCmd || Pressing.overrides.ctrl) && Timeline.selected.length > 1;
values_changed = false;
if (!clicked.selected && !e1.shiftKey && Timeline.selected.length != 0) {
if (!clicked.selected && !e1.shiftKey && !Pressing.overrides.shift && Timeline.selected.length != 0) {
clicked.select()
} else if (clicked && !clicked.selected) {
clicked.select({shiftKey: true})
@ -824,7 +824,7 @@ onVueSetup(function() {
let value_diff = 0;
if (Timeline.vue.graph_editor_open) {
value = -offset[1] / Timeline.vue.graph_size;
var round_num = canvasGridSize(e2.shiftKey, e2.ctrlOrCmd);
var round_num = canvasGridSize(e2.shiftKey || Pressing.overrides.shift, e2.ctrlOrCmd || Pressing.overrides.ctrl);
if (Toolbox.selected.id === 'resize_tool') {
round_num *= 0.1;
}

View File

@ -185,11 +185,11 @@ class Keybind {
}
isTriggered(event) {
return (
(this.key === event.which || (this.key == 1001 && event instanceof MouseEvent)) &&
(this.ctrl === event.ctrlKey || this.ctrl == null ) &&
(this.shift === event.shiftKey || this.shift == null ) &&
(this.alt === event.altKey || this.alt == null ) &&
(this.meta === event.metaKey || this.meta == null )
(this.key === event.which || (this.key == 1001 && event instanceof MouseEvent)) &&
(this.ctrl === (event.ctrlKey || Pressing.overrides.ctrl) || this.ctrl == null ) &&
(this.shift === (event.shiftKey || Pressing.overrides.shift)|| this.shift == null ) &&
(this.alt === (event.altKey || Pressing.overrides.alt) || this.alt == null ) &&
(this.meta === event.metaKey || this.meta == null )
)
}
record() {

View File

@ -81,7 +81,7 @@ class Group extends OutlinerNode {
//Clear Old Group
if (Group.selected) Group.selected.unselect()
if (event.shiftKey !== true && event.ctrlOrCmd !== true) {
if ((event.shiftKey || Pressing.overrides.shift) !== true && (event.ctrlOrCmd || Pressing.overrides.ctrl) !== true) {
selected.length = 0
}
//Select This Group

View File

@ -398,7 +398,7 @@ class OutlinerElement extends OutlinerNode {
if (Modes.animate && this.constructor != NullObject) return false;
//Shiftv
var just_selected = []
if (event && event.shiftKey === true && this.getParentArray().includes(selected[selected.length-1]) && !Modes.paint && isOutlinerClick) {
if (event && (event.shiftKey === true || Pressing.overrides.shift) && this.getParentArray().includes(selected[selected.length-1]) && !Modes.paint && isOutlinerClick) {
var starting_point;
var last_selected = selected[selected.length-1]
this.getParentArray().forEach((s, i) => {
@ -429,7 +429,7 @@ class OutlinerElement extends OutlinerNode {
})
//Control
} else if (event && !Modes.paint && (event.ctrlOrCmd || event.shiftKey )) {
} else if (event && !Modes.paint && (event.ctrlOrCmd || event.shiftKey || Pressing.overrides.ctrl || Pressing.overrides.shift)) {
if (selected.includes(this)) {
selected.replace(selected.filter((e) => {
return e !== this
@ -638,7 +638,7 @@ function dropOutlinerObjects(item, target, event, order) {
} else {
var items = [item];
}
if (event.altKey) {
if (event.altKey || Pressing.overrides.alt) {
Undo.initEdit({elements: [], outliner: true, selection: true})
selected.empty();
} else {
@ -670,7 +670,7 @@ function dropOutlinerObjects(item, target, event, order) {
}
items.forEach(function(item) {
if (item && item !== target) {
if (event.altKey) {
if (event.altKey || Pressing.overrides.alt) {
if (item instanceof Group) {
var dupl = item.duplicate()
place(dupl)
@ -691,7 +691,7 @@ function dropOutlinerObjects(item, target, event, order) {
if (Format.bone_rig) {
Canvas.updateAllBones()
}
if (event.altKey) {
if (event.altKey || Pressing.overrides.alt) {
updateSelection()
Undo.finishEdit('Duplicate selection', {elements: selected, outliner: true, selection: true})
} else {
@ -1136,7 +1136,7 @@ Interface.definePanels(function() {
convertTouchEvent(e2);
if (e2.target.classList.contains('outliner_toggle') && e2.target.getAttribute('toggle') == key) {
let [node] = eventTargetToNode(e2.target);
if (key == 'visibility' && e2.altKey && !affected.length) {
if (key == 'visibility' && (e2.altKey || Pressing.overrides.alt) && !affected.length) {
let new_affected = Outliner.elements.filter(node => !node.selected);
value = !(new_affected[0] && new_affected[0][key]);
new_affected.forEach(node => {

View File

@ -679,7 +679,7 @@ class Preview {
}
if (data.cube.parent.type === 'group' && (
Animator.open ||
event.shiftKey ||
event.shiftKey || Pressing.overrides.shift ||
(!Format.rotate_cubes && Format.bone_rig && ['rotate_tool', 'pivot_tool'].includes(Toolbox.selected.id))
)) {
data.cube.parent.select().showInOutliner();
@ -809,7 +809,7 @@ class Preview {
var scope = this;
if (this.movingBackground) {
if (event.shiftKey) {
if (event.shiftKey || Pressing.overrides.shift) {
this.background.size = limitNumber( this.background.before.size + (event.offsetY - this.selection.start_y), 0, 10e3)
} else {
this.background.x = this.background.before.x + (event.offsetX - this.selection.start_x);
@ -976,7 +976,7 @@ class Preview {
unselectAll()
elements.forEach((element) => {
let isSelected;
if ((event.shiftKey || event.ctrlOrCmd) && scope.selection.old_selected.indexOf(element) >= 0) {
if ((event.shiftKey || event.ctrlOrCmd || Pressing.overrides.ctrl || Pressing.overrides.shift) && scope.selection.old_selected.indexOf(element) >= 0) {
isSelected = true
} else if (element.visibility) {

View File

@ -1454,7 +1454,7 @@
var difference = value - (previousValue||0)
Project.display_settings[display_slot][channel][axisNumber] += difference
if (event.shiftKey && channel === 'scale') {
if ((event.shiftKey || Pressing.overrides.shift) && channel === 'scale') {
var val = Project.display_settings[display_slot][channel][axisNumber]
Project.display_settings[display_slot][channel][(axisNumber+1)%3] = val
Project.display_settings[display_slot][channel][(axisNumber+2)%3] = val

View File

@ -728,8 +728,8 @@ BARS.defineActions(function() {
min: 0, max: 360, default: 0,
},
getInterval(e) {
if (e.shiftKey) return 12.5;
if (e.ctrlOrCmd) return 1;
if (e.shiftKey || Pressing.overrides.shift) return 12.5;
if (e.ctrlOrCmd || Pressing.overrides.ctrl) return 1;
return 4
},
get: function() {
@ -748,8 +748,8 @@ BARS.defineActions(function() {
min: 0, max: 100, default: 0,
},
getInterval(e) {
if (e.shiftKey) return 10;
if (e.ctrlOrCmd) return 1;
if (e.shiftKey || Pressing.overrides.shift) return 10;
if (e.ctrlOrCmd || Pressing.overrides.ctrl) return 1;
return 2
},
get: function() {
@ -768,8 +768,8 @@ BARS.defineActions(function() {
min: 0, max: 100, default: 100,
},
getInterval(e) {
if (e.shiftKey) return 10;
if (e.ctrlOrCmd) return 1;
if (e.shiftKey || Pressing.overrides.shift) return 10;
if (e.ctrlOrCmd || Pressing.overrides.ctrl) return 1;
return 2
},
get: function() {

View File

@ -187,12 +187,12 @@ const Painter = {
Painter.painting = true;
if (data) {
var is_line = event.shiftKey && Painter.current.cube == data.cube && Painter.current.face == data.face
var is_line = (event.shiftKey || Pressing.overrides.shift) && Painter.current.cube == data.cube && Painter.current.face == data.face
Painter.current.cube = data.cube;
Painter.current.face = data.face;
} else {
//uv editor
var is_line = event.shiftKey;
var is_line = (event.shiftKey || Pressing.overrides.shift);
}
if (is_line) {
@ -528,7 +528,7 @@ const Painter = {
let diff_x = x - Painter.startPixel[0];
let diff_y = y - Painter.startPixel[1];
if (event.shiftKey) {
if (event.shiftKey || Pressing.overrides.shift) {
let clamp = Math.floor((Math.abs(diff_x) + Math.abs(diff_y))/2);
diff_x = diff_x>0 ? clamp : -clamp;
diff_y = diff_y>0 ? clamp : -clamp;
@ -643,7 +643,7 @@ const Painter = {
let diff_x = x - Painter.startPixel[0];
let diff_y = y - Painter.startPixel[1];
if (event.shiftKey) {
if (event.shiftKey || Pressing.overrides.shift) {
let length = Math.sqrt(Math.pow(diff_x, 2) + Math.pow(diff_y, 2));
let ratio = Math.abs(diff_x) / Math.abs(diff_y);

View File

@ -1223,7 +1223,7 @@ function loadTextureDraggable() {
Undo.initEdit({elements: cubes_list})
cubes_list.forEach(cube => {
if (cube instanceof Cube) {
cube.applyTexture(tex, data.shiftKey || [data.face])
cube.applyTexture(tex, data.shiftKey || Pressing.overrides.shift || [data.face])
}
})
Undo.finishEdit('Apply texture')

View File

@ -258,7 +258,7 @@ class UVEditor {
var offset = scope.jquery.frame.offset();
event.offsetX = event.clientX - offset.left;
event.offsetY = event.clientY - offset.top;
if (!dragging_not_clicking && event.ctrlOrCmd) {
if (!dragging_not_clicking && (event.ctrlOrCmd || Pressing.overrides.ctrl)) {
scope.reverseSelect(event)
}
dragging_not_clicking = false;
@ -1785,7 +1785,7 @@ const uv_dialog = {
BARS.updateConditions()
},
select: function(id, event) {
if (event.shiftKey) {
if (event.shiftKey || Pressing.overrides.shift) {
uv_dialog.selection.push(id)
} else {
if (uv_dialog.selection.includes(id) && uv_dialog.selection.length === 1) {