Platforms to show: All Mac Windows Linux Cross-Platform
Back to NSWorkspaceMBS class.
NSWorkspaceMBS.selectFile(file as folderitem) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns true on success.
For Windows, please use WinOpenFolderAndSelectItemsMBS function.
Some examples using this method:
NSWorkspaceMBS.setDesktopImageURL(file as folderitem, screen as NSScreenMBS, options as dictionary, byref error as NSErrorMBS) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
file: The image file. The file must not be nil.
screen: The screen to set the desktop image on.
options: The options dictionary may contain any of the Desktop Image Dictionary Keys (NSWorkspaceDesktopImageScalingKey, NSWorkspaceDesktopImageAllowClippingKey or NSWorkspaceDesktopImageFillColorKey), which control how the image is scaled on the screen.
error: A error that is returned by-reference if setting the image fails.
Returns true if the image was set as the desktop, otherwise false. If false is returned, the error parameter provides additional information.
You should not present a user interface for picking the options. Instead, choose appropriate defaults and allow the user to adjust them in the System Preference Pane.
Available in Mac OS X v10.6 and later.
NSWorkspaceMBS.setIcon(image as NSImageMBS, file as folderitem, flags as Integer = 0) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
image: The image to use as the icon for the file or directory.
file: The full path of the file or directory.
flags: The icon representations to generate from the image. You specify this value by combining the appropriate NSWorkspaceIconCreationOptions constants, listed in Constants, using the C bitwise OR operator. Specify 0 if you want to generate icons in all available icon representation formats.
Returns true if the icon was set; otherwise, false.
The image can be an arbitrary image, with or without transparency. This image is automatically scaled (as needed) to generate the icon representations. The file or folder must exist and be writable by the user.
It is recommended that applications include the NSExclude10_4ElementsIconCreationOption option for compatibility with pre-Mac OS X v10.3 Finder. Icons that include the high resolution elements prevent custom icons from being displayed on earlier systems.
Before setting icon, make sure you close all Binarystream, Textoutputstream or other classes which may have the file open.
See also:
NSWorkspaceMBS.setIcon(image as NSImageMBS, path as string, flags as Integer = 0) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
image: The image to use as the icon for the file or directory.
path: The full path of the file or directory.
flags: The icon representations to generate from the image. You specify this value by combining the appropriate NSWorkspaceIconCreationOptions constants, listed in Constants, using the C bitwise OR operator. Specify 0 if you want to generate icons in all available icon representation formats.
Returns true if the icon was set; otherwise, false.
The image can be an arbitrary image, with or without transparency. This image is automatically scaled (as needed) to generate the icon representations. The file or folder must exist and be writable by the user.
It is recommended that applications include the NSExclude10_4ElementsIconCreationOption option for compatibility with pre-Mac OS X v10.3 Finder. Icons that include the high resolution elements prevent custom icons from being displayed on earlier systems.
Before setting icon, make sure you close all Binarystream, Textoutputstream or other classes which may have the file open.
See also:
NSWorkspaceMBS.showSearchResultsForQueryString(queryString as string) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Cocoa | MBS MacCocoa Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns true if the communication with Finder was successful, otherwise false.
Finder becomes the active application, if possible. The user can further refine the search via the Finder user interface.
Available in Mac OS X v10.6 and later.
NSWorkspaceMBS.typeOfFile(File as folderitem, byref error as NSErrorMBS) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Cocoa | MBS MacCocoa Plugin | 12.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
file: The absolute path of the file.
Error: If the Uniform Type Identifier of the file at absolutePath can't be determined, outError contains an NSError object that describes why.
Returns a string containing the uniform type identifier of the file at absoluteFilePath. If no UTI can be determined the return value is "".
If the file at the specified path is a symbolic link, the type of the symbolic link is returned.
See also:
NSWorkspaceMBS.typeOfFile(Path as string, byref error as NSErrorMBS) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Cocoa | MBS MacCocoa Plugin | 12.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
file: The absolute path of the file.
Error: If the Uniform Type Identifier of the file at absolutePath can't be determined, outError contains an NSError object that describes why.
Returns a string containing the uniform type identifier of the file at absoluteFilePath. If no UTI can be determined the return value is "".
If the file at the specified path is a symbolic link, the type of the symbolic link is returned.
See also:
NSWorkspaceMBS.unmountAndEjectDevice(item as folderitem, byref e as NSErrorMBS) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns true if the volume was unmounted and ejected successfully, otherwise false, for example, if the volume is not ejectable.
error: If the operation fails, this error contains more information about the failure.
NSWorkspaceMBS.URLForApplicationToOpenURL(url as string) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Cocoa | MBS MacCocoa Plugin | 12.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
url: The URL of the file to open.
Returns the URL of the default application that would open the specified url. Returns "" if no application is able to open the url, or if the file url does not exist.
This is the programmatic equivalent of double clicking a document in the Finder.
NSWorkspaceMBS.URLForApplicationWithBundleIdentifier(bundleIdentifier as string) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Cocoa | MBS MacCocoa Plugin | 12.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
bundleIdentifier: A bundle identifier specifying an application.
Returns the URL of the application, or "" if no application has the bundle identifier.
This uses various (currently unspecified) heuristics in case multiple apps have the same bundle ID.
The items on this page are in the following plugins: MBS MacCocoa Plugin.