Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

Previous items

NSWorkspaceMBS.NSWorkspaceRecycleOperation as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the file operation modes.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test")
dim tag as Integer
dim files(-1) as string
dim b as Boolean
dim source,dest as FolderItem

source=f.Parent

files.Append f.name

b=NSWorkspaceMBS.performFileOperation(NSWorkspaceMBS.NSWorkspaceRecycleOperation, source, dest, files, tag)

if b then
MsgBox "OK"
else
MsgBox "Failed"
end if
Notes: Move file to trash. The file is moved to the trash folder on the volume containing the file using the same semantics as NSWorkspaceMoveOperation. If a file with the same name currently exists in the trash folder, the new file is renamed. If no trash folder exists on the volume containing the file, the operation fails.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceScreensDidSleepNotification as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the notification names.
Notes:
Posted when the machine's screen goes to sleep.
The notification object is the shared NSWorkspace instance. The notification does not contain a userInfo dictionary.

Few applications are likely to be interested in this notification, but they may be useful for certain hardware-based drawing decisions, for example when using OpenGL.

Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceScreensDidWakeNotification as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the notification names.
Notes:
Posted when the machine's screens wake.
The notification object is the shared NSWorkspace instance. The notification does not contain a userInfo dictionary.

Few applications are likely to be interested in this notification, but they may be useful for certain hardware-based drawing decisions, for example when using OpenGL.

Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceSessionDidBecomeActiveNotification as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the notification names.
Notes:
Posted after a user session is switched in. This allows an application to re-enable some processing when a switched out session gets switched back in, for example.
The notification object is the shared NSWorkspace instance. The notification does not contain a userInfo dictionary.

Available in Mac OS X v10.3 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceSessionDidResignActiveNotification as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the notification names.
Notes:
Posted before a user session is switched out. This allows an application to disable some processing when its user session is switched out, and re-enable when that session gets switched back in, for example.
The notification object is the shared NSWorkspace instance. The notification does not contain a userInfo dictionary.

If an application is launched in an inactive session, NSWorkspaceSessionDidResignActiveNotification is sent after NSApplicationWillFinishLaunchingNotification and before sending NSApplicationDidFinishLaunchingNotification.

Available in Mac OS X v10.3 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceVolumeLocalizedNameKey as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the keys for the userinfo dictionary for the NSWorkspaceDidRenameVolumeNotification notification.
Notes:
String containing the user-visible name of the volume.
Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceVolumeOldLocalizedNameKey as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the keys for the userinfo dictionary for the NSWorkspaceDidRenameVolumeNotification notification.
Notes:
String containing the old user-visible name of the volume
Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceVolumeOldURLKey as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the keys for the userinfo dictionary for the NSWorkspaceDidRenameVolumeNotification notification.
Notes:
URL containing the old mount path of the volume
Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceVolumeURLKey as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the keys for the userinfo dictionary for the NSWorkspaceDidRenameVolumeNotification notification.
Notes:
URL containing the mount path of the volume.
Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceWillLaunchApplicationNotification as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the notification names.
Notes:
Posted when the Finder is about to launch an application.
The notification object is the shared NSWorkspace instance. In Mac OS X v10.6 and later the userInfo dictionary contains the NSWorkspaceApplicationKey key with a corresponding instance of NSRunningApplication that represents the affected application.

Available in Mac OS X v10.0 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceWillPowerOffNotification as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the notification names.
Notes:
Posted when the user has requested a logout or that the machine be powered off.
The notification object is the shared NSWorkspace instance. This notification does not contain a userInfo dictionary.
Available in Mac OS X v10.0 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceWillSleepNotification as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the notification names.
Notes:
Posted before the machine goes to sleep. An observer of this message can delay sleep for up to 30 seconds while handling this notification.
The notification object is the shared NSWorkspace instance. The notification does not contain a userInfo dictionary.

Available in Mac OS X v10.3 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.NSWorkspaceWillUnmountNotification as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: One of the notification names.
Notes:
Posted when the Finder is about to unmount a device.
This notification will not be delivered if a volume was forcibly and immediately made unavailable, such as when a FireWire drive is simply unplugged, because there is no chance to deliver it before the volume becomes unavailable.

The notification object is the shared NSWorkspace instance. The userInfo dictionary contains a key "NSDevicePath" that returns the path where the device was mounted, as a string.
Available in Mac OS X v10.0 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.openFile(file as folderitem) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 8.1 Yes No No Yes, macOS only No
Function: Opens the specified file specified using the default application associated with its type.
Example:
dim f as FolderItem

f=SpecialFolder.Desktop.Child("test.txt")

if NSWorkspaceMBS.openFile(f) then
MsgBox "Ok"
else
MsgBox "failed"
end if
Notes:
Returns true if the file was successfully opened; otherwise, false.
The sending application is deactivated before the request is sent.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.openFile(file as folderitem, appname as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 8.1 Yes No No Yes, macOS only No
Function: Opens a file using the specified application.
Example:
dim f as FolderItem
f=SpecialFolder.Desktop.Child("test.txt")

if NSWorkspaceMBS.openFile(f,"BBEdit") then
MsgBox "Ok"
else
MsgBox "failed"
end if
Notes:
Returns true if the file was successfully opened; otherwise, false.

The appName parameter need not be specified with a full path and, in the case of an application wrapper, may be specified with or without the .app extension, as described in "Use of .app Extension". The sending application is deactivated before the request is sent.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.openFile(file as folderitem, appname as string, Deactivate as boolean) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 8.1 Yes No No Yes, macOS only No
Function: Opens the specified file and optionally deactivates the sending application.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.file")

if NSWorkspaceMBS.openFile(f,"BBEdit",true) then
MsgBox "Ok"
else
MsgBox "failed"
end if
Notes:
appName: The name of the application to use when opening the file.

flag: If true, the sending application is deactivated before the request is sent, allowing the opening application to become the active application.

Returns true if the file was successfully opened; otherwise, false.

The appName parameter need not be specified with a full path and, in the case of an application wrapper, may be specified with or without the .app extension, as described in "Use of .app Extension". If appName is nil, the default application for the file's type is used.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.openURL(url as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 8.1 Yes No No Yes, macOS only No
Function: Opens the location at the specified URL.
Example:
if NSWorkspaceMBS.openURL("http://www.apple.com") then
MsgBox "Ok"
else
MsgBox "failed"
end if
Notes: Returns true if the location was successfully opened; otherwise, false.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.openURL(url as string, bundleIdentifier as string, options as Integer = &h00030000, AppleEventDescriptor as Variant = nil) as Boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 12.5 Yes No No Yes, macOS only No
Function: Opens one or more files from an array of URLs.
Notes:
url: A URL for the application to open.
bundleIdentifier: A bundle identifier string or "" to use the default system bindings. This value corresponds to the value in the CFBundleIdentifier key of the application's Info.plist file. For example, the bundle identifier of the TextEdit application is com.apple.TextEdit.
options: Options to use when launching the application. Values for this parameter are described in constants.
descriptor: Additional options specified in an AppleEvent-style descriptor. For example, you could use this parameter to specify additional documents to open when the application is launched.

Returns true if the application was found and launched; otherwise, false.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.performFileOperation(operation as string, source as folderitem, destination as folderitem, files() as string, byref tag as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 9.2 Yes No No Yes, macOS only No
Function: Performs a file operation on a set of files in a particular directory.
Notes:
operation: The file operation to perform. The possible values for this parameter are described in "Constants."

source: The full path to the directory containing the files on which to operate.

destination: The full path to the destination directory of the operation.

files: An array of folderitems specifying the names of the files and directories to be manipulated. Each string must not contain any path information other than the name of the file or directory. In other words, all of the files and directories must be located in the source directory and not in one if its subdirectories.

tag: On input, a integer variable; on return, this variable contains a negative integer if the operation fails, 0 if he operation was performed synchronously and succeeded, or a positive integer if the operation was performed asynchronously. If the value is a positive integer, the value is a tag that identifies the requested file operation.

Return Value: True if the operation succeeded; otherwise, false.

Discussion:
Some operations—such as moving, copying, and linking files—require a destination directory to be specified. If not, destination should be the empty string (""). Before this method returns, it posts an NSWorkspaceDidPerformFileOperationNotification to the NSWorkspace object's notification center.

Feedback, Comments & Corrections

NSWorkspaceMBS.preferredFilenameExtensionForType(typeName as string) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 9.6 Yes No No Yes, macOS only No
Function: Returns the preferred filename extension for the specified Uniform Type Identifier.
Example:
MsgBox NSWorkspaceMBS.preferredFilenameExtensionForType("public.jpeg")
// "jpeg" in German
Notes: The appropriate filename extension for typeName, or "" if no extension could be determined.

Feedback, Comments & Corrections

NSWorkspaceMBS.selectFile(file as folderitem) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 8.1 Yes No No Yes, macOS only No
Function: Selects the file in the Finder.
Example:
dim f as FolderItem

f=SpecialFolder.Desktop.Child("test.txt")

if NSWorkspaceMBS.selectFile(f) then
MsgBox "Ok"
else
MsgBox "failed"
end if
Notes:
Returns true on success.

For Windows, please use WinOpenFolderAndSelectItemsMBS function.

Feedback, Comments & Corrections

NSWorkspaceMBS.setDesktopImageURL(file as folderitem, screen as NSScreenMBS, options as dictionary, byref error as NSErrorMBS) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: Sets the desktop image for the given screen to the image at the specified URL.
Notes:
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.

Feedback, Comments & Corrections

NSWorkspaceMBS.setIcon(image as NSImageMBS, file as folderitem, flags as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 8.1 Yes No No Yes, macOS only No
Function: Sets the icon for the file or directory at the specified path.
Example:
dim f as FolderItem
dim p as Picture
dim img as NSImageMBS

f=SpecialFolder.Desktop.Child("test.txt")

p=newPicture(128,128,32)
p.Graphics.ForeColor=rgb(0,128,0)
p.Graphics.fillrect 0,0,128,128
p.Graphics.ForeColor=rgb(255,0,0)
p.Graphics.filloval 0,0,128,128

img=new NSImageMBS(p)

if NSWorkspaceMBS.setIcon(img,f,0) then
MsgBox "Ok. Icon may not be visible directly. Maybe you make a copy of the file to see it directly?"
else
MsgBox "failed"
end if
Notes:
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:

Feedback, Comments & Corrections

NSWorkspaceMBS.setIcon(image as NSImageMBS, path as string, flags as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 8.1 Yes No No Yes, macOS only No
Function: Sets the icon for the file or directory at the specified path.
Notes:
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:

Feedback, Comments & Corrections

NSWorkspaceMBS.showSearchResultsForQueryString(queryString as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 9.6 Yes No No Yes, macOS only No
Function: Displays a Spotlight search results window in Finder for the specified query string.
Notes:
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.

Feedback, Comments & Corrections

NSWorkspaceMBS.typeOfFile(File as folderitem, byref error as NSErrorMBS) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 12.5 Yes No No Yes, macOS only No
Function: Returns the uniform type identifier of the specified file, if it can be determined.
Notes:
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:

Feedback, Comments & Corrections

NSWorkspaceMBS.typeOfFile(Path as string, byref error as NSErrorMBS) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 12.5 Yes No No Yes, macOS only No
Function: Returns the uniform type identifier of the specified file, if it can be determined.
Notes:
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:

Feedback, Comments & Corrections

NSWorkspaceMBS.unmountAndEjectDevice(item as folderitem, byref e as NSErrorMBS) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: Unmounts and ejects the device at the specified path.
Example:
dim w as new NSWorkspaceMBS
dim disk as FolderItem = Volume(VolumeCount-1)

MsgBox disk.Name

dim e as NSErrorMBS
if w.unmountAndEjectDevice(disk, e) then
MsgBox "OK"
else
MsgBox "Error: "+e.localizedDescription
end if
Notes:
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.

Feedback, Comments & Corrections

NSWorkspaceMBS.URLForApplicationToOpenURL(url as string) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 12.5 Yes No No Yes, macOS only No
Function: Returns the URL to the default application that would be used to open the given URL.
Notes:
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.

Feedback, Comments & Corrections

NSWorkspaceMBS.URLForApplicationWithBundleIdentifier(bundleIdentifier as string) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 12.5 Yes No No Yes, macOS only No
Function: Returns the URL for the application with the specified identifier.
Notes:
bundleIdentifier: A bundle identifier specifying an application.

Returns the URL of the application, or nil if no application has the bundle identifier.
This uses various (currently unspecified) heuristics in case multiple apps have the same bundle ID.

Feedback, Comments & Corrections

Previous items

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





Links
MBS Xojo Plugins