mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-28 18:15:37 -05:00
1. painter add mouse event support
2. Palette and ScriptPane add mouse event support
This commit is contained in:
parent
b72abe9723
commit
29d26ba343
3 changed files with 22 additions and 28 deletions
|
@ -67,7 +67,7 @@ export default class Thumbs {
|
|||
}
|
||||
|
||||
static pageMouseDown (e) {
|
||||
if (isTablet && e.touches && (e.touches.length > 1)) {
|
||||
if (e.touches && (e.touches.length > 1)) {
|
||||
return;
|
||||
}
|
||||
if (ScratchJr.onHold) {
|
||||
|
@ -353,15 +353,9 @@ export default class Thumbs {
|
|||
}
|
||||
img.setAttribute('class', 'unselectable');
|
||||
tb.setAttribute('id', 'emptypage');
|
||||
if (isTablet) {
|
||||
tb.ontouchstart = function (evt) {
|
||||
Thumbs.clickOnEmptyPage(evt);
|
||||
};
|
||||
} else {
|
||||
tb.onmousedown = function (evt) {
|
||||
Thumbs.clickOnEmptyPage(evt);
|
||||
};
|
||||
}
|
||||
tb.onclick = function (evt) {
|
||||
Thumbs.clickOnEmptyPage(evt);
|
||||
};
|
||||
return tb;
|
||||
}
|
||||
|
||||
|
|
|
@ -225,16 +225,16 @@ export default class Paint {
|
|||
}
|
||||
|
||||
static detectGesture (e) {
|
||||
if (!e.touches) {
|
||||
return;
|
||||
}
|
||||
if (Camera.active) {
|
||||
return;
|
||||
}
|
||||
Paint.clearEvents(e);
|
||||
initialPoint = PaintAction.getScreenPt(e);
|
||||
deltaPoint = PaintAction.getScreenPt(e);
|
||||
var n = Math.min(3, e.touches.length);
|
||||
var n = 1;
|
||||
if (e.touches) {
|
||||
n = Math.min(3, e.touches.length);
|
||||
}
|
||||
var cmdForGesture = [Paint.ignore, Paint.mouseDown, Paint.pinchStart, Paint.Scroll];
|
||||
cmdForGesture[n](e);
|
||||
}
|
||||
|
@ -734,8 +734,6 @@ export default class Paint {
|
|||
for (var i = 0; i < pensizes.length; i++) {
|
||||
var ps = newHTML('div', 'pensizeholder', section);
|
||||
ps.key = i;
|
||||
ps.ontouchstart = setSize;
|
||||
ps.onmousedown = setSize;
|
||||
var setSize = function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
@ -743,6 +741,8 @@ export default class Paint {
|
|||
strokewidth = pensizes[Number(this.key)];
|
||||
Paint.selectPenSize(n);
|
||||
};
|
||||
ps.ontouchstart = setSize;
|
||||
ps.onmousedown = setSize;
|
||||
var c = newHTML('div', 'line t' + i, ps);
|
||||
Paint.drawPenSizeInColor(c);
|
||||
}
|
||||
|
|
|
@ -120,12 +120,6 @@ export default class Events {
|
|||
updatefcn = atdrag;
|
||||
if (isTablet) { // startDrag event setting
|
||||
delta = 10 * scaleMultiplier;
|
||||
window.ontouchmove = function (evt) {
|
||||
Events.mouseMove(evt);
|
||||
};
|
||||
window.ontouchend = function (evt) {
|
||||
Events.mouseUp(evt);
|
||||
};
|
||||
window.ontouchleave = function (evt) {
|
||||
Events.mouseUp(evt);
|
||||
};
|
||||
|
@ -134,13 +128,19 @@ export default class Events {
|
|||
};
|
||||
} else {
|
||||
delta = 7;
|
||||
window.onmousemove = function (evt) {
|
||||
Events.mouseMove(evt);
|
||||
};
|
||||
window.onmouseup = function (evt) {
|
||||
Events.mouseUp(evt);
|
||||
};
|
||||
}
|
||||
window.ontouchmove = function (evt) {
|
||||
Events.mouseMove(evt);
|
||||
};
|
||||
window.ontouchend = function (evt) {
|
||||
Events.mouseUp(evt);
|
||||
};
|
||||
window.onmousemove = function (evt) {
|
||||
Events.mouseMove(evt);
|
||||
};
|
||||
window.onmouseup = function (evt) {
|
||||
Events.mouseUp(evt);
|
||||
};
|
||||
}
|
||||
|
||||
static holdit (c, fcn) {
|
||||
|
|
Loading…
Reference in a new issue