Index: remoting/webapp/remoting.js |
diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js |
index a8ca35e6cbf032898bded2e497f732a04126f468..9eba4ac677c027c3229c59bc9a70aaadd61347fd 100644 |
--- a/remoting/webapp/remoting.js |
+++ b/remoting/webapp/remoting.js |
@@ -44,6 +44,7 @@ remoting.init = function() { |
document.getElementById('host-list-error')); |
remoting.toolbar = new remoting.Toolbar( |
document.getElementById('session-toolbar')); |
+ remoting.clipboard = new remoting.Clipboard(); |
refreshEmail_(); |
var email = remoting.oauth2.getCachedEmail(); |
@@ -51,7 +52,9 @@ remoting.init = function() { |
document.getElementById('current-email').innerText = email; |
} |
+ window.addEventListener('focus', pluginGotFocus_, false); |
window.addEventListener('blur', pluginLostFocus_, false); |
+ window.addEventListener('paste', pluginGotPaste_, false); |
// Parse URL parameters. |
var urlParams = getUrlParameters_(); |
@@ -124,6 +127,28 @@ remoting.clearOAuth2 = function() { |
}; |
/** |
+ * Callback function called when the browser window gets focus. |
+ */ |
+function pluginGotFocus_() { |
+ var documentCast = /** @type {remoting.Document} */ document; |
Jamie
2012/03/14 00:43:47
This can be simpler if you just annotate execComma
|
+ documentCast.execCommand("paste"); |
+} |
+ |
+/** |
+ * Callback function called when the browser window gets a paste operation. |
+ * |
+ * @param {Event} eventUncast |
+ * @return {boolean} |
+ */ |
+function pluginGotPaste_(eventUncast) { |
+ var event = /** @type {remoting.Event} */ eventUncast; |
+ if (event && event.clipboardData) { |
+ remoting.clipboard.toHost(event.clipboardData); |
+ } |
+ return false; |
+} |
+ |
+/** |
* Callback function called when the browser window loses focus. In this case, |
* release all keys to prevent them becoming 'stuck down' on the host. |
*/ |