Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

NSMutableAttributedStringMBS.addAttribute(name as string, value as Variant, range as NSRangeMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Adds an attribute with the given name and value to the characters in the specified range.
Example:
// create Hello World in red
dim a as NSAttributedStringMBS = NSAttributedStringMBS.attributedStringWithString("Hello World")
dim 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
Notes:
name: A string specifying the attribute name. Attribute keys can be supplied by another framework or can be custom ones you define. For information about where to find the system-supplied attribute keys, see the overview section in NSAttributedString Class Reference.
value: The attribute value associated with name.
Range: The range of characters to which the specified attribute/value pair applies.

You may assign any name/value pair you wish to a range of characters, in addition to the standard attributes described in the "Constants" section of NSAttributedString Additions. Raises an NSInvalidArgumentException if name or value is nil and an NSRangeException if any part of range lies beyond the end of the receiver's characters.

Plugin version 16.0 or newer ignores calls here with value = nil or empty name to avoid exceptions.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.addAttributes(attrs as Dictionary, range as NSRangeMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Adds the given collection of attributes to the characters in the specified range.
Notes:
attributes: A dictionary containing the attributes to add. Attribute keys can be supplied by another framework or can be custom ones you define. For information about where to find the system-supplied attribute keys, see the overview section in NSAttributedString Class Reference.
Range: The range of characters to which the specified attributes apply.

You may assign any name/value pair you wish to a range of characters, in addition to the standard attributes described in the "Constants" section of NSAttributedString Additions. Raises an NSInvalidArgumentException if attributes is nil and an NSRangeException if any part of range lies beyond the end of the receiver's characters.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.appendAttributedString(attrString as NSAttributedStringMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Adds the characters and attributes of a given attributed string to the end of the receiver.
Example:
const NSWritingDirectionNatural       = -1   // Determines direction using the Unicode Bidi Algorithm rules P2 and P3
const NSWritingDirectionLeftToRight = 0 // Left to right writing direction
const NSWritingDirectionRightToLeft = 1 // Right to left writing direction

const NSTextWritingDirectionEmbedding = 0
const NSTextWritingDirectionOverride = 2

dim t as NSTextStorageMBS = TextArea1.NSTextViewMBS.textStorage

// get hello in arabic
dim a as NSAttributedStringMBS = NSAttributedStringMBS.attributedStringWithString("مرحبا")
dim m as NSMutableAttributedStringMBS = a.mutableCopy

// now set attributes for right to left
m.addAttribute t.NSWritingDirectionAttributeName, array(NSWritingDirectionRightToLeft+NSTextWritingDirectionOverride), new NSRangeMBS(0,m.Length)

// and add to textarea
t.appendAttributedString m
Notes: attributedString: The string whose characters and attributes are added.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.applyFontTraits(FontTraitMask as Integer, offset as Integer, length as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Applies the font attributes specified by mask to the characters in a range.
Notes: See the NSFontManager class specification for a description of the font traits available. Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.AsCFMutableAttributedString as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 14.2 Yes No No Yes, macOS only No
Function: Returns a new CFMutableAttributedStringMBS object pointing to same mutable attributed string.
Example:
// make NS version
dim n as new NSAttributedStringMBS

if n.initWithString("Hello World") then

dim m as NSMutableAttributedStringMBS = n.mutableCopy

// convert
dim c as CFMutableAttributedStringMBS = m.AsCFMutableAttributedString

// and check content
MsgBox c.String
end if
Notes: For passing to functions which need a CFMutableAttributedStringMBS.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.beginEditing
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 9.6 Yes No No Yes, macOS only No
Function: Overridden by subclasses to buffer or optimize a series of changes to the receiver's characters or attributes, until it receives a matching endEditing message, upon which it can consolidate changes and notify any observers that it has changed.
Notes: You can nest pairs of beginEditing and endEditing messages.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.containsAttachmentsInRange(offset as Integer, length as Integer) as Boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Returns true if the receiver contains a property configured (NSAttachmentAttributeName with NSAttachmentCharacter) in range.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.deleteCharactersInRange(range as NSRangeMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 9.6 Yes No No Yes, macOS only No
Function: Deletes the characters in the given range along with their associated attributes.
Notes: Raises an NSRangeException if any part of aRange lies beyond the end of the receiver's characters.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.endEditing
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 9.6 Yes No No Yes, macOS only No
Function: Overridden by subclasses to consolidate changes made since a previous beginEditing message and to notify any observers of the changes.
Notes: The NSMutableAttributedString implementation does nothing. NSTextStorage, for example, overrides this method to invoke fixAttributesInRange and to inform its NSLayoutManager objects that they need to re-lay the text.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.fixAttachmentAttributeInRange(offset as Integer, length as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Cleans up attachment attributes in a range, removing all attachment attributes assigned to characters other than NSAttachmentCharacter.
Notes: Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.fixAttributesInRange(offset as Integer, length as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Invokes the other fix... methods, allowing you to clean up an attributed string with a single message.
Notes:
Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.

NSTextStorage subclasses that return YES from the fixesAttributesLazily method should avoid directly calling fixAttributesInRange: or else bracket such calls with beginEditing and endEditing messages.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.fixFontAttributeInRange(offset as Integer, length as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Fixes the font attribute in aRange, assigning default fonts to characters with illegal fonts for their scripts and otherwise correcting font attribute assignments.
Notes: For example, Kanji characters assigned a Latin font are reassigned an appropriate Kanji font. Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.fixParagraphStyleAttributeInRange(offset as Integer, length as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Fixes the paragraph style attributes in a range, assigning the first paragraph style attribute value in each paragraph to all characters of the paragraph.
Notes:
This method extends the range as needed to cover the last paragraph partially contained. A paragraph is delimited by any of these characters, the longest possible sequence being preferred to any shorter:

  • U+000D (\r or CR)
  • U+000A (\n or LF)
  • U+2029 (Unicode paragraph separator) \r\n, in that order (also known as CRLF)

Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.fontAttributesInRange(offset as Integer, length as Integer) as Dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Attributes which should be copied/pasted with "copy font".

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.insertAttributedString(attrString as NSAttributedStringMBS, location as UInt64)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Inserts the characters and attributes of the given attributed string into the receiver at the given index.
Notes:
attributedString: The string whose characters and attributes are inserted.
index: The index at which the characters and attributes are inserted.

The new characters and attributes begin at the given index and the existing characters and attributes from the index to the end of the receiver are shifted by the length of the attributed string. Raises an NSRangeException if index lies beyond the end of the receiver's characters.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.removeAttribute(name as string, range as NSRangeMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Removes the named attribute from the characters in the specified range.
Notes:
name: A string specifying the attribute name to remove. Attribute keys can be supplied by another framework or can be custom ones you define. For information about where to find the system-supplied attribute keys, see the overview section in NSAttributedString Class Reference.
Range: The range of characters from which the specified attribute is removed.

Raises an NSRangeException if any part of range lies beyond the end of the receiver's characters.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.replaceCharactersInRange(range as NSRangeMBS, attrString as NSAttributedStringMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Replaces the characters and attributes in a given range with the characters and attributes of the given attributed string.
Notes:
Range: The range of characters and attributes replaced.
attributedString: The attributed string whose characters and attributes replace those in the specified range.

Raises an NSRangeException if any part of range lies beyond the end of the receiver's characters.

See also:

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.replaceCharactersInRange(range as NSRangeMBS, text as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Replaces the characters in the given range with the characters of the given string.
Notes:
Range: A range specifying the characters to replace.
text: A string specifying the characters to replace those in range.

The new characters inherit the attributes of the first replaced character from range. Where the length of range is 0, the new characters inherit the attributes of the character preceding range if it has any, otherwise of the character following range.

Raises an NSRangeException if any part of range lies beyond the end of the receiver's characters.

See also:

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.rulerAttributesInRange(offset as Integer, length as Integer) as Dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Attributes which should be copied/pasted with "copy ruler".

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.setAlignment(alignment as Integer, offset as Integer, length as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Sets the alignment characteristic of the paragraph style attribute for the characters in aRange to alignment.
Notes: When attribute fixing takes place, this change will affect only paragraphs whose first character was included in aRange. Raises an NSRangeException if any part of a range lies beyond the end of the receiver’s characters.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.setAttributedString(attrString as NSAttributedStringMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Replaces the receiver's entire contents with the characters and attributes of the given attributed string.
Example:
// create Hello World in red
dim a as NSAttributedStringMBS = NSAttributedStringMBS.attributedStringWithString("Hello World")
dim 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
Notes: attributedString: The attributed string whose characters and attributes replace those in the receiver.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.setAttributes(attrs as Dictionary, range as NSRangeMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Sets the attributes for the characters in the specified range to the specified attributes.
Notes:
attributes: A dictionary containing the attributes to set. Attribute keys can be supplied by another framework or can be custom ones you define. For information about where to find the system-supplied attribute keys, see the overview section in NSAttributedString Class Reference.
Range: The range of characters whose attributes are set.

These new attributes replace any attributes previously associated with the characters in range. Raises an NSRangeException if any part of range lies beyond the end of the receiver's characters.

To set attributes for a zero-length NSMutableAttributedString displayed in a text view, use the NSTextView method setTypingAttributes.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.setBaseWritingDirection(writingDirection as Integer, offset as Integer, length as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Sets the base writing direction for the characters in range to writingDirection.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.subscriptRange(offset as Integer, length as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Decrements the value of the superscript attribute for characters in a range by 1.
Example:
TextArea1.Text = "Hello World"

dim n as NSTextViewMBS = TextArea1.NSTextViewMBS
dim s as NSTextStorageMBS = n.textStorage

s.subscriptRange(6,5)

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.superscriptRange(offset as Integer, length as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Increments the value of the superscript attribute for characters in a range by 1.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.unscriptRange(offset as Integer, length as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Removes the superscript attribute from the characters in a range.

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.updateAttachmentsFromPath(file as folderitem)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 15.0 Yes No No Yes, macOS only No
Function: Updates all attachments based on files contained in the RTFD file package at path.

See also:

Feedback, Comments & Corrections

NSMutableAttributedStringMBS.updateAttachmentsFromPath(path as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 15.0 Yes No No Yes, macOS only No
Function: Updates all attachments based on files contained in the RTFD file package at path.

See also:

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins