/** * When using the default functionality of the browser, getting/setting clipboard contents is * solved quite well, and it uses the external clipboard. Thus this method is redundant in case * it's called from paste event! For the same reason, it is not called from there. * * <p>However, we may call the same thing from GeoGebraWeb context menu, and in that case the form * of this method is just Okay. * * @return String */ public static String getClipboardContents(Runnable onFocusChange) { String clipboard = null; if (isChromeWebapp()) { // use chrome web app paste API clipboard = getSystemClipboardChromeWebapp(); if (onFocusChange != null) { onFocusChange.run(); } } else if (Browser.isInternetExplorer()) { clipboard = getSystemClipboardIE(); } else { // use internal clipboard clipboard = staticClipboardString; } return clipboard; }
/** * When using the default functionality of the browser, getting/setting clipboard contents is * solved quite well, and it uses the external clipboard. Thus this method is redundant in case * it's called from copy or cut events, maybe does the same thing twice in Internet Explorer. * * <p>However, we may call the same thing from GeoGebraWeb context menu, and in that case the form * of this method is just Okay. Note that in order to make the staticClipboardString function well * from context menu, we need to set it every case this method is called, and every case the * cut/paste events happen. * * @param value String */ public static void setClipboardContents(String value, Runnable onFocusChange) { if (isChromeWebapp()) { // use chrome web app copy API copyToSystemClipboardChromeWebapp(value); if (onFocusChange != null) { onFocusChange.run(); } } else if (Browser.isInternetExplorer()) { // App.debug("is IE"); copyToSystemClipboardIE(value); } // use internal clipboard too, every time staticClipboardString = value; copyToSystemClipboard(value); }