Skip to content

Commit

Permalink
v1.2.3 - Fix bug with readonly inputs
Browse files Browse the repository at this point in the history
Setting an input to readonly prevented copying the text inside of it.
  • Loading branch information
goldfire committed Nov 7, 2016
1 parent e12d480 commit 483ef7f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
37 changes: 18 additions & 19 deletions CanvasInput.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*!
* CanvasInput v1.2.2
* CanvasInput v1.2.3
* http://goldfirestudios.com/blog/108/CanvasInput-HTML5-Canvas-Text-Input
*
* (c) 2013-2015, James Simpson of GoldFire Studios
* (c) 2013-2016, James Simpson of GoldFire Studios
* goldfirestudios.com
*
* MIT License
Expand Down Expand Up @@ -783,30 +783,29 @@
self._hasFocus = true;
if (self._readonly) {
self._hiddenInput.readOnly = true;
return;
} else {
self._hiddenInput.readOnly = false;
}

// update the cursor position
self._cursorPos = (typeof pos === 'number') ? pos : self._clipText().length;
// update the cursor position
self._cursorPos = (typeof pos === 'number') ? pos : self._clipText().length;

// clear the place holder
if (self._placeHolder === self._value) {
self._value = '';
self._hiddenInput.value = '';
}
// clear the place holder
if (self._placeHolder === self._value) {
self._value = '';
self._hiddenInput.value = '';
}

self._cursor = true;
self._cursor = true;

// setup cursor interval
if (self._cursorInterval) {
clearInterval(self._cursorInterval);
// setup cursor interval
if (self._cursorInterval) {
clearInterval(self._cursorInterval);
}
self._cursorInterval = setInterval(function() {
self._cursor = !self._cursor;
self.render();
}, 500);
}
self._cursorInterval = setInterval(function() {
self._cursor = !self._cursor;
self.render();
}, 500);

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

0 comments on commit 483ef7f

Please sign in to comment.