Skip to content

Commit

Permalink
Merge pull request #7 from trinketapp/feat/different-focus-element
Browse files Browse the repository at this point in the history
another attempt to fix the focus problem
  • Loading branch information
albertjan authored Jun 5, 2018
2 parents ddb155c + e80329c commit e21ddde
Show file tree
Hide file tree
Showing 5 changed files with 360 additions and 353 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Processing.js",
"version": "1.6.11",
"version": "1.6.12",
"main": "processing.js",
"ignore": [
"bundle",
Expand Down
9 changes: 6 additions & 3 deletions processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -7511,7 +7511,7 @@ module.exports = (function commonFunctions(undef) {
/**
* Touch and Mouse event handling
*/
module.exports = function withTouch(p, curElement, attachEventHandler, detachEventHandlersByType, document, PConstants, undef) {
module.exports = function withTouch(p, curElement, attachEventHandler, detachEventHandlersByType, document, PConstants, focusElement, undef) {

// List of mouse event types
var mouseTypes = ['mouseout','mousemove','mousedown','mouseup','DOMMouseScroll','mousewheel','touchstart'];
Expand Down Expand Up @@ -7757,7 +7757,8 @@ module.exports = function withTouch(p, curElement, attachEventHandler, detachEve
*/
curElement.onmousedown = function () {
// make sure focus happens, but nothing else
curElement.focus();
var e = focusElement || curElement;
e.focus();
return false;
};

Expand Down Expand Up @@ -9767,7 +9768,9 @@ module.exports = function setupParser(Processing, options) {
}
}

extend.withTouch(p, aDoubleBufferCanvas, attachEventHandler, detachEventHandlersByType, document, PConstants);
var focusElement = aCode && aCode.options && aCode.options.focusElement ? aCode.options.focusElement : aDoubleBufferCanvas;

extend.withTouch(p, aDoubleBufferCanvas, attachEventHandler, detachEventHandlersByType, document, PConstants, focusElement);

// custom functions and properties are added here
if(aFunctions) {
Expand Down
Loading

0 comments on commit e21ddde

Please sign in to comment.