Class MacClipboard
- All Implemented Interfaces:
NativeClipboard
NSPasteboard, on the main thread, which is the UI
thread.
What this process offers is promised: a pasteboard item names its types and a data provider,
an object of a class made here, which is sent pasteboard:item:provideDataForType: when
a program pastes. Files are the exception, written at once as one URL an item, which is what
Finder and the file panels read. What is still promised as this closes is provided then, so
that a copy outlives the application, as on Windows.
An item takes only uniform type identifiers, which an application's media type with its
slash is not. Such a name is written under the dynamic identifier the system derives for a
pasteboard type of that name (conforming to public.data), and is still found by the
name, by this toolkit and by any program that asks the pasteboard for it.
The pasteboard announces no change. Its change count is compared when the application becomes active, which is when another program's copy can first matter here, and each time the types are asked for.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Lets go of the system's resources.booleanisOwner()voidMakes this process the clipboard's owner.CompletableFuture<byte[]> Asks for the bytes of one type.voidsetChangeListener(Runnable listener) types()The types on the clipboard as the system last reported them, without asking it again.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface limn.backend.lwjgl.transfer.NativeClipboard
madeAhead
-
Constructor Details
-
MacClipboard
public MacClipboard()Main thread.- Throws:
RuntimeException- when the Objective-C runtime will not make the owner's class; the caller then keeps GLFW's text clipboard
-
-
Method Details
-
isOwner
public boolean isOwner()- Specified by:
isOwnerin interfaceNativeClipboard- Returns:
- whether what the clipboard holds was put there by the last
NativeClipboard.offer(java.util.List<java.lang.String>, java.util.function.Function<java.lang.String, byte[]>)of this process and has not been replaced since
-
types
Description copied from interface:NativeClipboardThe types on the clipboard as the system last reported them, without asking it again.- Specified by:
typesin interfaceNativeClipboard- Returns:
- canonical type names, best first; empty when the clipboard is empty or unknown
-
read
Description copied from interface:NativeClipboardAsks for the bytes of one type.- Specified by:
readin interfaceNativeClipboard- Parameters:
type- one ofNativeClipboard.types()- Returns:
- the bytes, completed on whatever thread the implementation reads on; completed exceptionally when the type is not, or no longer, there
-
offer
Description copied from interface:NativeClipboardMakes this process the clipboard's owner.- Specified by:
offerin interfaceNativeClipboard- Parameters:
types- what is offered, best first; empty empties the clipboardbytes- the bytes of one of those types, asked for when a program wants them; it may be called on any thread and may block, and answers null for what it cannot make
-
setChangeListener
- Specified by:
setChangeListenerin interfaceNativeClipboard- Parameters:
listener- called, on any thread, after the clipboard's types or its owner change, anNativeClipboard.offer(java.util.List<java.lang.String>, java.util.function.Function<java.lang.String, byte[]>)of this process included; replaces the one before
-
close
public void close()Description copied from interface:NativeClipboardLets go of the system's resources. The clipboard is not used afterwards.- Specified by:
closein interfaceNativeClipboard
-