From b8c5da317372bf6ed3349c9b023b9b1203b26267 Mon Sep 17 00:00:00 2001 From: Reeju Bhattacharya Date: Sun, 6 Feb 2022 22:42:59 +0530 Subject: [PATCH 1/6] fixes issue #5191 along with minor grammatical edits --- src/events/mouse.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/events/mouse.js b/src/events/mouse.js index ae449c3191..5380952720 100644 --- a/src/events/mouse.js +++ b/src/events/mouse.js @@ -984,7 +984,10 @@ p5.prototype._onwheel = function(e) { * Note that not all browsers support this feature. * This enables you to create experiences that aren't limited by the mouse moving out of the screen * even if it is repeatedly moved into one direction. - * For example, a first person perspective experience. + * For example, a first person perspective experience. It is recommended to + * use requestPointerLock() as a result + * of any user interaction, like mouseClicked() + * or keyPressed() * * @method requestPointerLock * @example @@ -993,7 +996,6 @@ p5.prototype._onwheel = function(e) { * let cam; * function setup() { * createCanvas(100, 100, WEBGL); - * requestPointerLock(); * cam = createCamera(); * } * @@ -1003,6 +1005,10 @@ p5.prototype._onwheel = function(e) { * cam.tilt(movedY * 0.001); * sphere(25); * } + * + * function mouseClicked() { + * requestPointerLock(); + * } * * * @@ -1024,8 +1030,8 @@ p5.prototype.requestPointerLock = function() { /** * The function exitPointerLock() - * exits a previously triggered pointer Lock - * for example to make ui elements usable etc + * exits a previously triggered pointer Lock. + * For example, it might be used to make UI elements usable once again. * * @method exitPointerLock * @example From 1c193bf3f0c668f07f1bc484d1bd775f722d1b93 Mon Sep 17 00:00:00 2001 From: Reeju Bhattacharya Date: Wed, 16 Feb 2022 22:21:48 +0530 Subject: [PATCH 2/6] initial commit --- src/dom/dom.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/dom/dom.js b/src/dom/dom.js index a845db2203..cd8558c0ef 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -943,6 +943,7 @@ p5.prototype.createRadio = function() { }; self.selected = function(value) { + // console.log('Hello'); let result = null; if (value === undefined) { for (const option of self._getOptionsArray()) { @@ -952,6 +953,12 @@ p5.prototype.createRadio = function() { } } } else { + // forEach loop to uncheck all radio buttons before + // setting any one as checked. + self + ._getOptionsArray() + .forEach(option => option.removeAttribute('checked')); + for (const option of self._getOptionsArray()) { if (option.value === value) { option.setAttribute('checked', true); From ef166a57a87a40babb64a0bb398f378605cb4a2b Mon Sep 17 00:00:00 2001 From: Reeju Bhattacharya Date: Wed, 16 Feb 2022 23:03:28 +0530 Subject: [PATCH 3/6] remove comments --- src/dom/dom.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index cd8558c0ef..fd8de5a868 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -943,7 +943,6 @@ p5.prototype.createRadio = function() { }; self.selected = function(value) { - // console.log('Hello'); let result = null; if (value === undefined) { for (const option of self._getOptionsArray()) { From c029a7004147c5c03342759534a59a47a70611a7 Mon Sep 17 00:00:00 2001 From: Reeju Bhattacharya Date: Wed, 16 Feb 2022 23:04:32 +0530 Subject: [PATCH 4/6] Revert "fixes issue #5191 along with minor grammatical edits" This reverts commit b8c5da317372bf6ed3349c9b023b9b1203b26267. reverts commit from another pull request --- src/events/mouse.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/events/mouse.js b/src/events/mouse.js index 5380952720..ae449c3191 100644 --- a/src/events/mouse.js +++ b/src/events/mouse.js @@ -984,10 +984,7 @@ p5.prototype._onwheel = function(e) { * Note that not all browsers support this feature. * This enables you to create experiences that aren't limited by the mouse moving out of the screen * even if it is repeatedly moved into one direction. - * For example, a first person perspective experience. It is recommended to - * use requestPointerLock() as a result - * of any user interaction, like mouseClicked() - * or keyPressed() + * For example, a first person perspective experience. * * @method requestPointerLock * @example @@ -996,6 +993,7 @@ p5.prototype._onwheel = function(e) { * let cam; * function setup() { * createCanvas(100, 100, WEBGL); + * requestPointerLock(); * cam = createCamera(); * } * @@ -1005,10 +1003,6 @@ p5.prototype._onwheel = function(e) { * cam.tilt(movedY * 0.001); * sphere(25); * } - * - * function mouseClicked() { - * requestPointerLock(); - * } * * * @@ -1030,8 +1024,8 @@ p5.prototype.requestPointerLock = function() { /** * The function exitPointerLock() - * exits a previously triggered pointer Lock. - * For example, it might be used to make UI elements usable once again. + * exits a previously triggered pointer Lock + * for example to make ui elements usable etc * * @method exitPointerLock * @example From 52c4969e4b8a2afc601122666e292c9906affeda Mon Sep 17 00:00:00 2001 From: Reeju Bhattacharya Date: Fri, 18 Feb 2022 02:46:33 +0530 Subject: [PATCH 5/6] made changes as suggested --- src/dom/dom.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index fd8de5a868..2adc1261ff 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -954,12 +954,14 @@ p5.prototype.createRadio = function() { } else { // forEach loop to uncheck all radio buttons before // setting any one as checked. - self - ._getOptionsArray() - .forEach(option => option.removeAttribute('checked')); + self._getOptionsArray().forEach(option => { + option.removeAttribute('checked'); + option.checked = false; + }); for (const option of self._getOptionsArray()) { if (option.value === value) { + option.checked = true; option.setAttribute('checked', true); result = option; } From 9499111266e35e29261f90e850dfbb1f372ec639 Mon Sep 17 00:00:00 2001 From: Reeju Bhattacharya Date: Fri, 18 Feb 2022 02:52:25 +0530 Subject: [PATCH 6/6] minor linting changes --- src/dom/dom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 2adc1261ff..9bd87a1b97 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -955,14 +955,14 @@ p5.prototype.createRadio = function() { // forEach loop to uncheck all radio buttons before // setting any one as checked. self._getOptionsArray().forEach(option => { - option.removeAttribute('checked'); option.checked = false; + option.removeAttribute('checked'); }); for (const option of self._getOptionsArray()) { if (option.value === value) { - option.checked = true; option.setAttribute('checked', true); + option.checked = true; result = option; } }