Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CanvasInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,20 @@
}
});

// setup the paste listener
self._hiddenInput.addEventListener('paste', function(e) {
// Hidden input's value isn't updated until after the paste event is finished.
// Delay the updates until it's done so the pasted value exists.
setTimeout(function() {
// update the canvas input state information from the hidden input
self._value = self._hiddenInput.value;
self._cursorPos = self._hiddenInput.selectionStart;
// update selection to hidden input's selection in case user did keyboard-based selection
self._selection = [self._hiddenInput.selectionStart, self._hiddenInput.selectionEnd];
self.render();
}, 1);
});

// add this to the buffer
inputs.push(self);
self._inputsIndex = inputs.length - 1;
Expand Down