From b458b1d5431d4dcca6fc488a0c68dbcc0fbd1f07 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 16 Oct 2019 15:48:18 +0200 Subject: [PATCH] addded "enableLinks" flag to Morphic text elements off by default this flag lets you specify whether a text might contain a clickable URL or not. --- src/morphic.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/morphic.js b/src/morphic.js index aee64fc7..757072e4 100644 --- a/src/morphic.js +++ b/src/morphic.js @@ -1177,7 +1177,7 @@ /*global window, HTMLCanvasElement, FileReader, Audio, FileList, Map*/ -var morphicVersion = '2019-October-14'; +var morphicVersion = '2019-October-16'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -8660,6 +8660,7 @@ StringMorph.prototype.init = function ( this.isBold = bold || false; this.isItalic = italic || false; this.isEditable = false; + this.enableLinks = false; // set to "true" if I can contain clickable URLs this.isNumeric = isNumeric || false; this.isPassword = false; this.shadowOffset = shadowOffset || new Point(0, 0); @@ -9173,7 +9174,7 @@ StringMorph.prototype.mouseClickLeft = function (pos) { cursor.gotoPos(pos); } this.currentlySelecting = true; - } else { + } else if (this.enableLinks) { var slot = this.slotAt(pos), clickedText, startMark, @@ -9189,7 +9190,8 @@ StringMorph.prototype.mouseClickLeft = function (pos) { } endMark = slot; - while (endMark < this.text.length - 1 && isURLChar(this.text[endMark + 1])) { + while (endMark < this.text.length - 1 && + isURLChar(this.text[endMark + 1])) { endMark += 1; } @@ -9199,6 +9201,8 @@ StringMorph.prototype.mouseClickLeft = function (pos) { } else { this.escalateEvent('mouseClickLeft', pos); } + } else { + this.escalateEvent('mouseClickLeft', pos); } }; @@ -9367,6 +9371,7 @@ TextMorph.prototype.init = function ( this.maxLineWidth = 0; this.backgroundColor = null; this.isEditable = false; + this.enableLinks = false; // set to "true" if I can contain clickable URLs //additional properties for ad-hoc evaluation: this.receiver = null;