Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSAttributedStringMBS class.

NSAttributedStringMBS.attributedStringWithAdaptiveImageGlyph(adaptiveImageGlyph as NSAdaptiveImageGlyphMBS, withAttributes as dictionary) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 25.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Creates an attributed string with an adaptive image glyph and applies the specified attributes to it.

adaptiveImageGlyph: The adaptive image glyph to place in the string. Typically, you get this type from the text input system.
attributes: The attributes to apply to the adaptive image glyph. Specify an empty dictionary to create the string without any extra attributes.

NSAttributedStringMBS.attributedStringWithAttachment(attachment as NSTextAttachmentMBS) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 15.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates an attributed string with an attachment.
Example
Var content as MemoryBlock = "Hello World"
Var f as NSFileWrapperMBS = NSFileWrapperMBS.initRegularFileWithContents(content)
f.filename = "HelloWorld.txt"

Var a as new NSTextAttachmentMBS(f)
Var s as NSAttributedStringMBS = NSAttributedStringMBS.attributedStringWithAttachment(a)

This is a convenience method for creating an attributed string containing an attachment using NSAttachmentCharacter as the base character.

NSAttributedStringMBS.attributedStringWithAttributedString(text as NSAttributedStringMBS) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 11.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of the given attributed string.

NSAttributedStringMBS.attributedStringWithDocFormat(data as memoryblock) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initializes string with content of given DOC file data.

documentAttributes: Optional dictionary to receive the attributes.

See also:

Some examples using this method:

NSAttributedStringMBS.attributedStringWithDocFormat(data as memoryblock, byref DocumentAttributes as dictionary) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initializes string with content of given DOC file data.

documentAttributes: Optional dictionary to receive the attributes.

See also:

NSAttributedStringMBS.attributedStringWithHTMLOld(data as string) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 11.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given HTML file data.

With plugin version 9.4 the attributedStringWithHTML method uses the system function to parse html. The old plugin function is available with the name attributedStringWithHTMLOld.

NSAttributedStringMBS.attributedStringWithPath(file as folderitem) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 11.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of file at the given file.
Example
// load rtfd file into textarea
Var file as FolderItem = SpecialFolder.Desktop.Child("test.rtfd")
Var n as NSAttributedStringMBS = NSAttributedStringMBS.attributedStringWithPath(file)
Var t as NSTextViewMBS = TextArea1.NSTextViewMBS
t.textStorage.setAttributedString(n)

documentAttributes: Optional dictionary to receive the attributes.

See also:

Some examples using this method:

NSAttributedStringMBS.attributedStringWithRTF(data as memoryblock) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 11.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given RTF file data.

documentAttributes: Optional dictionary to receive the attributes.

See also:

Some examples using this method:

NSAttributedStringMBS.attributedStringWithRTF(data as memoryblock, byref DocumentAttributes as dictionary) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given RTF file data.

documentAttributes: Optional dictionary to receive the attributes.

See also:

NSAttributedStringMBS.attributedStringWithRTFD(data as memoryblock) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 11.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given RTFD file data.

documentAttributes: Optional dictionary to receive the attributes.

See also:

NSAttributedStringMBS.attributedStringWithRTFD(data as memoryblock, byref DocumentAttributes as dictionary) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given RTFD file data.

documentAttributes: Optional dictionary to receive the attributes.

See also:

NSAttributedStringMBS.attributedStringWithString(text as string) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 11.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given plain text.
Example
// create Hello World in red
Var a as NSAttributedStringMBS = NSAttributedStringMBS.attributedStringWithString("Hello World")
Var m as NSMutableAttributedStringMBS = a.mutableCopy

m.addAttribute(a.NSForegroundColorAttributeName, NSColorMBS.redColor, new NSRangeMBS(0, m.length))

// put it in a textarea
TextArea1.NSTextViewMBS.textStorage.setAttributedString m

documentAttributes: Optional dictionary to receive the attributes.

See also:

Some examples using this method:

NSAttributedStringMBS.attributedStringWithString(text as string, withAttributes as dictionary) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given plain text.

documentAttributes: Optional dictionary to receive the attributes.

See also:

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


The biggest plugin in space...