Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSPasteboardMBS class.

NSPasteboardMBS.addType(type as string) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Adds promises for the specified types to the first pasteboard item.

types: An array of strings, each of which specifies a type of data that can be provided to the pasteboard.

Returns the new change count, or 0 if there was an error adding the types.

This method adds promises for the specified types to the first pasteboard item.

You use this methods to declare additional types of data for the first pasteboard item in the receiver. You can also use it to replace existing types added by a previous declareTypes or addTypes call.

The types parameter specifies the types of data you are promising to the pasteboard. The types should be ordered according to the preference of the source application, with the most preferred type coming first (typically, the richest representation). New types are added to the end of the list containing any existing types, if any.

If you specify a type that has already been declared, this method replaces the owner of that type with the value in newOwner. In addition, any data already already written to the pasteboard for that type is removed.

NSPasteboardMBS.addTypes(types() as string) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Adds promises for the specified types to the first pasteboard item.

types: An array of strings, each of which specifies a type of data that can be provided to the pasteboard.

Returns the new change count, or 0 if there was an error adding the types.

This method adds promises for the specified types to the first pasteboard item.

You use this methods to declare additional types of data for the first pasteboard item in the receiver. You can also use it to replace existing types added by a previous declareTypes or addTypes call.

The types parameter specifies the types of data you are promising to the pasteboard. The types should be ordered according to the preference of the source application, with the most preferred type coming first (typically, the richest representation). New types are added to the end of the list containing any existing types, if any.

If you specify a type that has already been declared, this method replaces the owner of that type with the value in newOwner. In addition, any data already already written to the pasteboard for that type is removed.

NSPasteboardMBS.changeCount as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the receiver's change count.
Example
dim p as new NSPasteboardMBS(NSPasteboardMBS.NSGeneralPboard)

MsgBox str(p.changeCount)

The change count starts at zero when a client creates the receiver and becomes the first owner. The change count subsequently increments each time the pasteboard ownership changes.

The change count is also returned from clearContents and declareTypes. You can therefore record the change count at the time that you take ownership of the pasteboard and later compare it with the value returned from changeCount to determine whether you still have ownership.

NSPasteboardMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a new NSPasteboardMBS object linked to the general NSPasteboard object.
Example
dim p as new NSPasteboardMBS

MsgBox join(p.types,EndOfLine)

On success the handle property is not 0.

See also:

NSPasteboardMBS.Constructor(name as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a new NSPasteboardMBS object linked to the pasteboard with the specified name.
Example
dim p as new NSPasteboardMBS(NSPasteboardMBS.NSFindPboard)

// shows last find string
MsgBox p.stringForType(p.NSPasteboardTypeString)

On success the handle property is not 0.

See also:

NSPasteboardMBS.dataForType(type as string) as Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Get the data for the specified type from the first item in the receiver that contains the type or sets the given data as the representation for the specified type for the first item on the receiver.
Example
dim p as new NSPasteboardMBS

// may have chr(0) on the end!
MsgBox p.dataForType(p.NSPasteboardTypeString)

Returns a data object containing the data for the specified type from the first item in the receiver that contains the type, or "" if the contents of the pasteboard changed since they were last checked.

This method may also return nil if the pasteboard server cannot supply the data in time—for example, if the pasteboard's owner is slow in responding to a pasteboard:provideDataForType: message and the interprocess communication times out.

Errors other than a timeout raise a NSPasteboardCommunicationException (a NSExceptionMBS in Xojo).

If "" is returned, the application should put up a panel informing the user that it was unable to carry out the paste operation.

For standard text data types such as string, RTF, and RTFD, the text data from each item is returned as one combined result separated by newlines.
(Read and Write computed property)

NSPasteboardMBS.declareType(type as string) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Prepares the receiver for a change in its contents by declaring the new types of data it will contain.

type: An strings that specify the type of data that may be added to the new pasteboard. The types should be ordered according to the preference of the source application, with the most preferred type coming first (typically, the richest representation).

Returns the receiver's new change count.

This method is the equivalent of invoking clearContents, implicitly writing the first pasteboard item, and then calling addTypes to promise types for the first pasteboard item.

In Mac OS X v10.5 and earlier, this method is the first step in writing data to the pasteboard and must precede the messages that actually write the data. A declareTypes message essentially changes the contents of the receiver: It invalidates the current contents of the receiver and increments its change count.

NSPasteboardMBS.declareTypes(types() as string) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Prepares the receiver for a change in its contents by declaring the new types of data it will contain.

type: An array of Strings that specify the types of data that may be added to the new pasteboard. The types should be ordered according to the preference of the source application, with the most preferred type coming first (typically, the richest representation).

Returns the receiver's new change count.

This method is the equivalent of invoking clearContents, implicitly writing the first pasteboard item, and then calling addTypes to promise types for the first pasteboard item.

In Mac OS X v10.5 and earlier, this method is the first step in writing data to the pasteboard and must precede the messages that actually write the data. A declareTypes message essentially changes the contents of the receiver: It invalidates the current contents of the receiver and increments its change count.

Some examples using this method:

NSPasteboardMBS.name as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the receiver's name.
Example
dim p as new NSPasteboardMBS

MsgBox p.name

NSPasteboardMBS.propertyListForType(type as string) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Clipboard MBS MacBase Plugin 13.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The property list for the specified type from the first item in the receiver that contains the type.

dataType: The pasteboard data type containing the property-list data.

The property list for the specified type from the first item in the receiver that contains the type. This object consists of NSArray, NSData, NSDictionary, or NSString objects—or any combination thereof.

This method invokes the dataForType method.
You must send types or availableTypeFromArray before invoking propertyListForType.
(Read and Write computed property)

NSPasteboardMBS.releaseGlobally

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Releases the receiver's resources in the pasteboard server.

After this method is invoked, no other application can use the receiver.

A temporary, privately named pasteboard can be released this way when it is no longer needed, but a standard pasteboard should never be released globally.

NSPasteboardMBS.SetPasteboardItems(items() as Variant) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 21.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Writes pasteboard items to the pasteboard.
Example
Dim paths() As String

paths.Append "/Users/cs/Pictures/test1.jpg"
paths.Append "/Users/cs/Pictures/test2.png"
paths.Append "/Users/cs/Pictures/test3.jpg"

Dim n As NSPasteboardMBS = NSPasteboardMBS.generalPasteboard

Dim files() As Variant
For Each path As String In paths

files.Append new FolderItem(path, FolderItem.PathModes.Native)

Next

Call n.clearContents

If n.SetPasteboardItems(files) Then
Break // okay
Else
Break // failed
End If

This method allows you to mix NSPasteboardItemMBS, folderitem, NSURLMBS, strings, NSAttributedStringMBS and other data to put on clipboard.
Returns true if the array was successfully added, otherwise false.

See also:

NSPasteboardMBS.stringForType(type as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Get/Set the given string as the representation for the specified type for the first item on the receiver.
Example
dim p as new NSPasteboardMBS

MsgBox p.stringForType(p.NSPasteboardTypeString)

A concatenation of the strings for the specified type from all the items in the receiver that contain the type, or nil if none of the items contain strings of the specified type.

This method invokes dataForType to obtain the string. If the string cannot be obtained, stringForType returns "". See dataForType for a description of what will cause "" to be returned.

In Mac OS X v10.6 and later, if the receiver contains multiple items that can provide string, RTF, or RTFD data, the text data from each item is returned as a combined result separated by newlines.
(Read and Write computed property)

NSPasteboardMBS.types as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 10.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns an array of the receiver's supported data types.
Example
dim p as new NSPasteboardMBS

MsgBox join(p.types,EndOfLine)

An array of Strings containing the union of the types of data declared for all the pasteboard items on the receiver. The returned types are listed in the order they were declared.

You must send a types or availableTypeFromArray message before reading any data from an NSPasteboard object.

NSPasteboardMBS.URLFromPasteboard as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 13.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Reads the URL string off of pasteboard.

Returns "" if pasteboard does not contain data of type NSURLPboardType.

Some examples using this method:

NSPasteboardMBS.writeURLToPasteboard(URL as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipboard MBS MacBase Plugin 13.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Writes the receiver to pasteboard.

You must declare an NSURLPboardType data type for pasteboard before invoking this method; otherwise it returns without doing anything.

The items on this page are in the following plugins: MBS MacBase Plugin.


The biggest plugin in space...