Skip to content

Commit 483ef7f

Browse files
committed
v1.2.3 - Fix bug with readonly inputs
Setting an input to readonly prevented copying the text inside of it.
1 parent e12d480 commit 483ef7f

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

CanvasInput.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*!
2-
* CanvasInput v1.2.2
2+
* CanvasInput v1.2.3
33
* http://goldfirestudios.com/blog/108/CanvasInput-HTML5-Canvas-Text-Input
44
*
5-
* (c) 2013-2015, James Simpson of GoldFire Studios
5+
* (c) 2013-2016, James Simpson of GoldFire Studios
66
* goldfirestudios.com
77
*
88
* MIT License
@@ -783,30 +783,29 @@
783783
self._hasFocus = true;
784784
if (self._readonly) {
785785
self._hiddenInput.readOnly = true;
786-
return;
787786
} else {
788787
self._hiddenInput.readOnly = false;
789-
}
790788

791-
// update the cursor position
792-
self._cursorPos = (typeof pos === 'number') ? pos : self._clipText().length;
789+
// update the cursor position
790+
self._cursorPos = (typeof pos === 'number') ? pos : self._clipText().length;
793791

794-
// clear the place holder
795-
if (self._placeHolder === self._value) {
796-
self._value = '';
797-
self._hiddenInput.value = '';
798-
}
792+
// clear the place holder
793+
if (self._placeHolder === self._value) {
794+
self._value = '';
795+
self._hiddenInput.value = '';
796+
}
799797

800-
self._cursor = true;
798+
self._cursor = true;
801799

802-
// setup cursor interval
803-
if (self._cursorInterval) {
804-
clearInterval(self._cursorInterval);
800+
// setup cursor interval
801+
if (self._cursorInterval) {
802+
clearInterval(self._cursorInterval);
803+
}
804+
self._cursorInterval = setInterval(function() {
805+
self._cursor = !self._cursor;
806+
self.render();
807+
}, 500);
805808
}
806-
self._cursorInterval = setInterval(function() {
807-
self._cursor = !self._cursor;
808-
self.render();
809-
}, 500);
810809

811810
// move the real focus to the hidden input
812811
var hasSelection = (self._selection[0] > 0 || self._selection[1] > 0);

0 commit comments

Comments
 (0)