From d7cd1e8f44d65c2feeeba13bf3d50d5ef058f546 Mon Sep 17 00:00:00 2001 From: FAL Date: Mon, 11 Jan 2021 01:36:08 +0900 Subject: [PATCH 1/3] docs: improve inline docs of `windowResized()` add description about `return false`, add @param `[event]` --- src/core/environment.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/environment.js b/src/core/environment.js index 8b6c6d0a09..f5dc0a861c 100644 --- a/src/core/environment.js +++ b/src/core/environment.js @@ -421,9 +421,13 @@ p5.prototype.windowHeight = getWindowHeight(); /** * The windowResized() function is called once * every time the browser window is resized. This is a good place to resize the - * canvas or do any other adjustments to accommodate the new window size. + * canvas or do any other adjustments to accommodate the new window size.

+ * Browsers may have different default behaviors attached to various UI + * events. To prevent any default behavior for this event, add "return false" + * to the end of the method. * * @method windowResized + * @param {Object} [event] optional UIEvent callback argument. * @example *
* function setup() { From cdbade2b1fdf6933702cd5d5cad8570b8afe0550 Mon Sep 17 00:00:00 2001 From: FAL Date: Mon, 11 Jan 2021 02:25:58 +0900 Subject: [PATCH 2/3] docs: improve inline docs of event handler funcs add @return as they may `return false` --- src/core/environment.js | 1 + src/events/keyboard.js | 3 +++ src/events/mouse.js | 8 +++++++- src/events/touch.js | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/environment.js b/src/core/environment.js index f5dc0a861c..711a8bd73f 100644 --- a/src/core/environment.js +++ b/src/core/environment.js @@ -428,6 +428,7 @@ p5.prototype.windowHeight = getWindowHeight(); * * @method windowResized * @param {Object} [event] optional UIEvent callback argument. + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* function setup() { diff --git a/src/events/keyboard.js b/src/events/keyboard.js index 3258abb9e7..f497f403e9 100644 --- a/src/events/keyboard.js +++ b/src/events/keyboard.js @@ -122,6 +122,7 @@ p5.prototype.keyCode = 0; * behavior for this event, add "return false" to the end of the method. * * @method keyPressed + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* @@ -194,6 +195,7 @@ p5.prototype._onkeydown = function(e) { * behavior for this event, add "return false" to the end of the method. * * @method keyReleased + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* @@ -253,6 +255,7 @@ p5.prototype._onkeyup = function(e) { * to the end of the method. * * @method keyTyped + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* diff --git a/src/events/mouse.js b/src/events/mouse.js index b243bf2f30..be2dc252c7 100644 --- a/src/events/mouse.js +++ b/src/events/mouse.js @@ -487,6 +487,7 @@ p5.prototype._setMouseButton = function(e) { * * @method mouseMoved * @param {Object} [event] optional MouseEvent callback argument. + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* @@ -542,6 +543,7 @@ p5.prototype._setMouseButton = function(e) { * * @method mouseDragged * @param {Object} [event] optional MouseEvent callback argument. + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* @@ -624,6 +626,7 @@ p5.prototype._onmousemove = function(e) { * * @method mousePressed * @param {Object} [event] optional MouseEvent callback argument. + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* @@ -703,6 +706,7 @@ p5.prototype._onmousedown = function(e) { * * @method mouseReleased * @param {Object} [event] optional MouseEvent callback argument. + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* @@ -781,6 +785,7 @@ p5.prototype._ondragover = p5.prototype._onmousemove; * * @method mouseClicked * @param {Object} [event] optional MouseEvent callback argument. + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* @@ -849,6 +854,7 @@ p5.prototype._onclick = function(e) { * * @method doubleClicked * @param {Object} [event] optional MouseEvent callback argument. + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* @@ -939,7 +945,7 @@ p5.prototype._pmouseWheelDeltaY = 0; * * @method mouseWheel * @param {Object} [event] optional WheelEvent callback argument. - * + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* diff --git a/src/events/touch.js b/src/events/touch.js index 96be3492fe..f795fbd6fb 100644 --- a/src/events/touch.js +++ b/src/events/touch.js @@ -78,6 +78,7 @@ function getTouchInfo(canvas, w, h, e, i = 0) { * * @method touchStarted * @param {Object} [event] optional TouchEvent callback argument. + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* @@ -158,6 +159,7 @@ p5.prototype._ontouchstart = function(e) { * * @method touchMoved * @param {Object} [event] optional TouchEvent callback argument. + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* @@ -230,6 +232,7 @@ p5.prototype._ontouchmove = function(e) { * * @method touchEnded * @param {Object} [event] optional TouchEvent callback argument. + * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
* From 45c759d01108467758779fbdc2220b409bfef537 Mon Sep 17 00:00:00 2001 From: FAL Date: Mon, 11 Jan 2021 02:30:54 +0900 Subject: [PATCH 3/3] docs: improve inline docs of key event handlers add @param `[event]` --- src/events/keyboard.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/events/keyboard.js b/src/events/keyboard.js index f497f403e9..a29862e265 100644 --- a/src/events/keyboard.js +++ b/src/events/keyboard.js @@ -122,6 +122,7 @@ p5.prototype.keyCode = 0; * behavior for this event, add "return false" to the end of the method. * * @method keyPressed + * @param {Object} [event] optional KeyboardEvent callback argument. * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
@@ -195,6 +196,7 @@ p5.prototype._onkeydown = function(e) { * behavior for this event, add "return false" to the end of the method. * * @method keyReleased + * @param {Object} [event] optional KeyboardEvent callback argument. * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *
@@ -255,6 +257,7 @@ p5.prototype._onkeyup = function(e) { * to the end of the method. * * @method keyTyped + * @param {Object} [event] optional KeyboardEvent callback argument. * @return {*} false if any default behavior should be prevented for this event. (Optional) * @example *