Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

Next items

NSWorkspaceMBS.absolutePathForAppBundleWithIdentifier(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 absolute file-system path of an application bundle.
Notes:
bundleIdentifier: The bundle identifier string. 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.

Returns the file system path to the application bundle identified by bundleIdentifier, or "" if the bundle cannot be found.

Feedback, Comments & Corrections

NSWorkspaceMBS.activateFileViewerSelectingFiles(Files() as folderitem)
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: Activates the Finder, and opens one or more windows selecting the specified files.
Example:
dim file as FolderItem = SpecialFolder.Pictures.Child("mbs.jpg") // some file

dim w as new NSWorkspaceMBS
dim files() as FolderItem

files.Append file

// show in Finder
w.activateFileViewerSelectingFiles(files)
Notes: Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.activateFileViewerSelectingURLs(URLs() 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: Activates the Finder, and opens one or more windows selecting the specified files.
Notes: Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.desktopImageOptionsForScreen(screen as NSScreenMBS) as dictionary
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: Returns the desktop image options for the given screen.
Example:
dim w as new NSWorkspaceMBS
dim m as NSScreenMBS = NSScreenMBS.mainScreen
dim dic as Dictionary = w.desktopImageOptionsForScreen(m)

break // check in debugger
Notes:
screen: The screen for which to get the desktop image options.

Returns a dictionary containing key-value pairs. Keys can be NSWorkspaceDesktopImageScalingKey, NSWorkspaceDesktopImageAllowClippingKey or NSWorkspaceDesktopImageFillColorKey.
Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.desktopImageURLForScreen(screen as NSScreenMBS) as folderitem
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: Returns the folderitem for the desktop image for the given screen.
Example:
dim w as new NSWorkspaceMBS
dim m as NSScreenMBS = NSScreenMBS.mainScreen
dim file as FolderItem = w.desktopImageURLForScreen(m)

MsgBox file.AbsolutePath
Notes:
screen: The screen for which to get the desktop image.
Returns the desktop image.
Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.fileLabelColors as NSColorMBS()
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: Returns the corresponding array of file label colors for the file labels.
Example:
dim w as new NSWorkspaceMBS
dim labels() as string = w.fileLabels
dim colors() as NSColorMBS = w.fileLabelColors
dim lines() as string

dim u as Integer = UBound(Colors)
for i as Integer = 0 to u
dim co as NSColorMBS = colors(i)

lines.Append labels(i)+": "+str(co.colorValue)
next

MsgBox Join(lines,EndOfLine)
Notes:
This array has the same number of elements as fileLabels, and the color at a given index corresponds to the label at the same index.

You can listen for notifications named NSWorkspaceDidChangeFileLabelsNotification to be notified when file labels change which may result in changes to the order of the fileLabelColors.

Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.fileLabels 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: Returns the array of file labels as strings.
Example:
dim w as new NSWorkspaceMBS
dim labels() as string = w.fileLabels

MsgBox Join(labels, EndOfLine)
Notes:
You can listen for notifications named NSWorkspaceDidChangeFileLabelsNotification to be notified when file labels change.
Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.findApplications
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: Examines all applications and updates the records of registered services and file types.
Example:
NSWorkspaceMBS.findApplications

Feedback, Comments & Corrections

NSWorkspaceMBS.frontmostApplication as NSRunningApplicationMBS
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: Gets the frontmost application, which is the application that will receive key events.
Example:
dim w as new NSWorkspaceMBS
dim n as NSRunningApplicationMBS = w.frontmostApplication

MsgBox n.localizedName
Notes: Requires Mac OS X 10.7.

Feedback, Comments & Corrections

NSWorkspaceMBS.fullPathForApplication(appname as string) as folderitem
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: Returns the full path for the specified application.
Example:
MsgBox NSWorkspaceMBS.fullPathForApplication("textedit").ShellPath
// shows /Applications/TextEdit.app
Notes: The full path for the application, or nil if the specified application was not found.

Feedback, Comments & Corrections

NSWorkspaceMBS.hideOtherApplications
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: Hides all applications other than the sender.
Example:
NSWorkspaceMBS.hideOtherApplications
Notes: The user can hide all applications except the current one by Command-Option-clicking on an application's Dock icon.

Feedback, Comments & Corrections

NSWorkspaceMBS.iconForFile(file as folderitem) as NSImageMBS
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: Returns an image containing the icon for the specified file.
Example:
dim f as FolderItem
f=SpecialFolder.Desktop.Child("test.txt")

dim n as NSImageMBS = NSWorkspaceMBS.iconForFile(f)
n.size = new NSSizeMBS(512,512)
Backdrop=n.CopyPictureWithMask
Notes:
The returned image has an initial size of 32 pixels by 32 pixels.
Returns nil on any error.

Feedback, Comments & Corrections

NSWorkspaceMBS.iconForFiles(files() as folderitem) as NSImageMBS
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: Returns an image containing the icon for the specified files.
Example:
dim w as new NSWorkspaceMBS
dim files() as FolderItem

dim folder as FolderItem = SpecialFolder.Pictures

// one file
files.Append folder.TrueItem(2)
canvas1.Backdrop = w.iconForFiles(files).CopyPictureWithMask

// two files
files.Append folder.TrueItem(3)
canvas2.Backdrop = w.iconForFiles(files).CopyPictureWithMask

// three files
files.Append folder.TrueItem(4)
canvas3.Backdrop = w.iconForFiles(files).CopyPictureWithMask
Notes:
files: An array of folderitems, each of which contains the full path to a file.

Returns the icon associated with the group of files.

If fullPaths specifies one file, that file's icon is returned. If fullPaths specifies more than one file, an icon representing the multiple selection is returned.

Feedback, Comments & Corrections

NSWorkspaceMBS.iconForFileType(filetype as string) as NSImageMBS
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: Returns an image containing the icon for files of the specified type.
Example:
Backdrop=NSWorkspaceMBS.iconForFileType("txt").CopyPictureWithMask
Notes:
filetype: The file type, which may be either a filename extension or an encoded HFS file type.

The returned image has an initial size of 32 pixels by 32 pixels.
Returns nil on any error.

Running this in a thread can lead to crashes.

Feedback, Comments & Corrections

NSWorkspaceMBS.isFilePackageAtPath(item as folderitem) 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: Determines whether the specified path is a file package.
Example:
dim w as new NSWorkspaceMBS
dim file as FolderItem = SpecialFolder.Applications.Child("iTunes.app")

// shows true for iTunes
MsgBox str(w.isFilePackageAtPath(file))
Notes: Returns true if the path identifies a file package; otherwise, false if the path does not exist, is not a directory, or is not a file package.

Feedback, Comments & Corrections

NSWorkspaceMBS.launchApplication(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: Launches the specified application.
Example:
if NSWorkspaceMBS.launchApplication("Textedit") then
MsgBox "Ok"
else
MsgBox "failed"
end if
Notes:
Returns true if the application was successfully launched or was already running; 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".

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.launchApplication(appname as string, showicon as boolean, autolaunch 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: Launches the specified application using additional options.
Example:
if NSWorkspaceMBS.launchApplication("Textedit",false,false) then
MsgBox "Ok"
else
MsgBox "failed"
end if
Notes:
appName: The name of the application to open.
showIcon: If false, the application's icon is not placed on the screen. (The icon still exists, though.)
autolaunch: If true, the autolaunch default is set as though the specified application were autolaunched at startup.

This method is provided to enable daemon-like applications that lack a normal user interface. Its use is not generally encouraged.
Returns true if the application is successfully launched or already running, and false if it can't be launched.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.launchApplicationAtFile(file as folderitem, options as UInt32 = 0, configuration as dictionary = nil) as NSRunningApplicationMBS
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: Launches the app at the specified file location.
Notes:
file: The application folderitem.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.

Returns reference to newly started application.

Available in Mac OS X v10.6 and later.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.launchApplicationAtFile(file as folderitem, options as UInt32, configuration as dictionary, byref error as NSErrorMBS) as NSRunningApplicationMBS
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: Launches the app at the specified file location.
Example:
dim w as new NSWorkspaceMBS
dim file as FolderItem = SpecialFolder.Applications.Child("Address Book.app")

dim error as NSErrorMBS
dim configuration as new Dictionary
dim options as Integer

// today we start 32 bit version
configuration.Value(w.NSWorkspaceLaunchConfigurationArchitecture) = w.NSBundleExecutableArchitectureI386

// and hide all others
options = w.NSWorkspaceLaunchAndHideOthers

dim r as NSRunningApplicationMBS = w.launchApplicationAtFile(file, options, configuration, error)

if r = nil then
MsgBox "Error: "+error.LocalizedDescription
else
MsgBox "Started: "+r.localizedName
end if
Notes:
file: The application folderitem.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.

Returns reference to newly started application.

Available in Mac OS X v10.6 and later.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.launchApplicationAtURL(URL as string, options as UInt32 = 0, configuration as dictionary = nil) as NSRunningApplicationMBS
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: Launches the app at the specified URL.
Notes:
url: The application URL.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.

Returns reference to newly started application.

Available in Mac OS X v10.6 and later.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.launchApplicationAtURL(URL as string, options as UInt32, configuration as dictionary, byref error as NSErrorMBS) as NSRunningApplicationMBS
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: Launches the app at the specified URL.
Notes:
url: The application URL.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.

Returns reference to newly started application.

Available in Mac OS X v10.6 and later.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.launchAppWithBundleIdentifier(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: Launches the application corresponding to the specified bundleIdentifier.
Notes:
bundleIdentifier: A bundle identifier string. 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.

Feedback, Comments & Corrections

NSWorkspaceMBS.localizedDescriptionForType(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 localized description for the specified Uniform Type Identifier.
Example:
MsgBox NSWorkspaceMBS.localizedDescriptionForType("public.jpeg")
// "JPEG-Bild" in German
Notes:
The localized description is suitable for displaying to the user.
Available in Mac OS X v10.5 and later.

Feedback, Comments & Corrections

NSWorkspaceMBS.menuBarOwningApplication as NSRunningApplicationMBS
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: Gets the menu bar owning application, which is the application that currently owns and draws the menu bar.
Example:
dim w as new NSWorkspaceMBS
dim n as NSRunningApplicationMBS = w.menuBarOwningApplication

MsgBox n.localizedName
Notes: Requires Mac OS X 10.7.

Feedback, Comments & Corrections

NSWorkspaceMBS.mountedLocalVolumePaths 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: Returns the mount points of all local volumes, not just the removable ones returned by mountedRemovableMedia.
Example:
dim w as new NSWorkspaceMBS
dim paths() as string = w.mountedLocalVolumePaths

MsgBox Join(paths, EndOfLine)
Notes: Returns an array of strings, each of which contains the full pathname of the mount point for any local volumes.

Feedback, Comments & Corrections

NSWorkspaceMBS.mountedRemovableMedia 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: Returns the full pathnames of all currently mounted removable disks.
Example:
dim w as new NSWorkspaceMBS
dim paths() as string = w.mountedRemovableMedia

MsgBox Join(paths, EndOfLine)
Notes:
Returns an array of strings, each of which contains the full pathname of a mounted removable disk.

If the computer provides an interrupt or other notification when the user inserts a disk into a drive, the Finder will mount the disk immediately. However, if no notification is given, the Finder won't be aware that a disk needs to be mounted. On such systems, an application should invoke either mountNewRemovableMedia or checkForRemovableMedia before invoking mountedRemovableMedia. Either of these methods cause the Finder to poll the drives to see if a disk is present. If a disk has been inserted but not yet mounted, these methods will cause the Finder to mount it.

The Disk button in an Open or Save panel invokes mountedRemovableMedia and mountNewRemovableMedia as part of its operation, so most applications won't need to invoke these methods directly.

Feedback, Comments & Corrections

NSWorkspaceMBS.noteFileSystemChanged
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: Informs the NSWorkspace object that the file system has changed.
Notes:
The NSWorkspace object then gets the status of all the files and directories it is interested in and updates itself appropriately. This method is used by many objects that write or delete files.

The NSDocument and NSSavePanel objects use this method when saving a file. If you create a file directly, you should call noteFileSystemChanged so that the Finder can update the folder if it is open.

Available in Mac OS X v10.0 and later. Deprecated in Mac OS X v10.6.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.noteFileSystemChanged(path as folderitem)
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: Informs the NSWorkspace object that the file system changed at the specified path.
Notes: The NSWorkspace object then gets the status of all the files and directories it is interested in and updates itself appropriately. This method is used by many objects that write or delete files.

See also:

Feedback, Comments & Corrections

NSWorkspaceMBS.notificationCenter as NSNotificationCenterMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacCocoa Plugin 9.7 Yes No No Yes, macOS only No
Function: Returns the notification center for workspace notifications.

Feedback, Comments & Corrections

Next items

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




Links
MBS Xojo Plugins