File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -232,11 +232,16 @@ p5.Element.prototype.class = function(c) {
232232 *
233233 */
234234p5 . Element . prototype . mousePressed = function ( fxn ) {
235+ // Prepend the mouse property setters to the event-listener.
236+ // This is required so that mouseButton is set correctly prior to calling the callback (fxn).
237+ // For details, see https://github.com/processing/p5.js/issues/3087.
235238 var eventPrependedFxn = function ( event ) {
236239 this . _pInst . _setProperty ( 'mouseIsPressed' , true ) ;
237240 this . _pInst . _setMouseButton ( event ) ;
241+ // Pass along the return-value of the callback:
238242 return fxn ( ) ;
239243 } ;
244+ // Pass along the event-prepended form of the callback.
240245 adjustListener ( 'mousedown' , eventPrependedFxn , this ) ;
241246 return this ;
242247} ;
You can’t perform that action at this time.
0 commit comments