Skip to content

Commit

Permalink
Allow readonly text to be selected
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfire committed Mar 19, 2015
1 parent 9a41e19 commit 2da76e9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions CanvasInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,6 @@
focus: function(pos) {
var self = this;

// if this is readonly, don't allow it to get focus
if (self._readonly) {
return;
}

// only fire the focus event when going from unfocussed
if (!self._hasFocus) {
self._onfocus(self);
Expand All @@ -710,6 +705,15 @@
delete self._selectionUpdated;
}

// if this is readonly, don't allow it to get focus
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;

Expand All @@ -719,7 +723,6 @@
self._hiddenInput.value = '';
}

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

// setup cursor interval
Expand Down Expand Up @@ -779,7 +782,7 @@
startText, endText;

// make sure the correct text field is being updated
if (!self._hasFocus) {
if (self._readonly || !self._hasFocus) {
return;
}

Expand Down

0 comments on commit 2da76e9

Please sign in to comment.