mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Fix error about setCapture not existing.
element.setCapture only seems to exist in Firefox. On most other browsers, our attempt to call it must have been generating a whinge in the console log all along. But Ben's commit bb16b5a70ddf77d turned that into a prominent alert box, triggered on every mouse click in the puzzle canvas. Worked around by wrapping both calls to setCapture in a local subroutine which checks if it's there before calling it. Also, setCapture turns out to be deprecated in any case, according to https://developer.mozilla.org/en-US/docs/Web/API/Element/setCapture . It looks as if the non-deprecated version is element.setPointerCapture: https://developer.mozilla.org/en-US/docs/Web/API/Element/setPointerCapture But it also looks as if that needs the 'pointerId' field that's only found in 'onpointerdown' events and not 'onmousedown' ones. So including that as an alternative will be a bigger job.
This commit is contained in:
11
emccpre.js
11
emccpre.js
@ -284,6 +284,13 @@ function dialog_cleanup() {
|
||||
onscreen_canvas.focus();
|
||||
}
|
||||
|
||||
function set_capture(element, event) {
|
||||
if (element.setCapture !== undefined) {
|
||||
element.setCapture(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Init function called early in main().
|
||||
function initPuzzle() {
|
||||
// Construct the off-screen canvas used for double buffering.
|
||||
@ -325,7 +332,7 @@ function initPuzzle() {
|
||||
event.preventDefault();
|
||||
button_phys2log[event.button] = logbutton;
|
||||
|
||||
onscreen_canvas.setCapture(true);
|
||||
set_capture(onscreen_canvas, event);
|
||||
};
|
||||
var mousemove = Module.cwrap('mousemove', 'boolean',
|
||||
['number', 'number', 'number']);
|
||||
@ -670,7 +677,7 @@ function initPuzzle() {
|
||||
} else {
|
||||
restore_pending = true;
|
||||
}
|
||||
resize_handle.setCapture(true);
|
||||
set_capture(resize_handle, event);
|
||||
event.preventDefault();
|
||||
};
|
||||
window.addEventListener("mousemove", function(event) {
|
||||
|
Reference in New Issue
Block a user