MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / paste

Method paste

src/org/opensourcephysics/display/OSPRuntime.java:2270–2293  ·  view source on GitHub ↗

Pastes from the clipboard and returns the pasted string. @return the pasted string, or null if none

(Consumer<String> whenDone)

Source from the content-addressed store, hash-verified

2268 * @return the pasted string, or null if none
2269 */
2270 public static String paste(Consumer<String> whenDone) {
2271 if (isJS) {
2272 if (whenDone != null)
2273 jsutil.getClipboardText(whenDone);
2274 return null;
2275 }
2276 Transferable data = null;
2277 try {
2278 Clipboard clipboard = getClipboard();
2279 data = clipboard.getContents(null);
2280 } catch (Exception e) {
2281 }
2282 if ((data != null) && data.isDataFlavorSupported(DataFlavor.stringFlavor)) {
2283 try {
2284 String s = (String) data.getTransferData(DataFlavor.stringFlavor);
2285 if (whenDone != null)
2286 whenDone.accept(s);
2287 return s;
2288 } catch (Exception ex) {
2289 ex.printStackTrace();
2290 }
2291 }
2292 return null;
2293 }
2294
2295 public static void copy(String s, ClipboardOwner owner) {
2296 StringSelection stringSelection = new StringSelection(s);

Callers 9

actionPerformedMethod · 0.95
pasteTabMethod · 0.95
hasPastableDataMethod · 0.95
actionPerformedMethod · 0.95
actionPerformedMethod · 0.95
ifClipboardPastableMethod · 0.95
createMenuBarMethod · 0.95
pasteActionMethod · 0.95

Calls 6

getClipboardMethod · 0.95
getClipboardTextMethod · 0.80
isDataFlavorSupportedMethod · 0.80
getTransferDataMethod · 0.80
acceptMethod · 0.65
getContentsMethod · 0.45

Tested by

no test coverage detected