Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a Paste Event to Update View #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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