Skip to content

TTMSFMXNativeUITextView

Usage

This component is based on the native iOS UITextView component and adds rich text editing capabilities. For more information about properties, methods and events that are not listed hereplease refer to the TMSFMXNativeUITextView component.

Published Properties

Property name Description
ContextMenuOptions When interacting with the TextView, a context menu pops up when selecting text. The context menus consists of various options such as cut, copy, and paste, select and select all editing capabilities. These menu items can be optionally disabled through this property;
DataDetectorTypes This property can be used to specify the types of data (phone numbers, http links …) that should be automatically converted to clickable URLs in the text view. When clicked, the text view opens the application responsible for handling the URL type and passes it the URL.

Public Properties

Property name Description
Selection: TTMSFMXNativeRichTextLibRange Gets and Sets the selection on the TextView.Selection is a record of text character position and length of selection in number of characters.
DataText: string (supported from iOS 6) Gets and Sets a compatible Archived XML String that can be used to persist the rich text contents of the TextView.

Public Methods

Each getter and setter of a specific attribute has optional parameters to apply the attribute value to text at a specific position and length inside the TextView. If the parameters are not specified, the value is applied to the selected text. Below is an example of setting a bold text:

//apply bold to the selected text
TMSFMXNativeUIRichTextView1.SetBold(True); 

//apply bold to the text at position 5 with a length of 3
TMSFMXNativeUIRichTextView1.SetBold(True, 5, 3);

Important notice

Not all functionality that is listed below is supported on iOS versions earlier than iOS 7. Functionality that is only supported on iOS 7 and later is marked.

Property name Description
AddBitmap(AValue: TBitmap; ALineHeight: Integer = -1; ALocation: Integer = -1); Inserts a bitmap in the TextView. By default, the lineheight is adapted to the bitmap height but can be overridden by setting ALineHeight parameter > -1. Also, by default, the bitmap is inserted at selection, unless the ALocation parameter is different than -1 and sets the insert character position.
AddBitmapFromFile(AValue: String; ALineHeight: integer –1; ALocation: Integer = -1); Inserts a bitmap from file in the TextView. By default, the lineheight is adapted to the bitmap height but can be overridden by setting ALineHeight parameter > -1. Also, by default, the bitmap is inserted at selection, unless the ALocation parameter is different than -1 and sets the insert character position.
CanRedo Returns a Boolean whether the TextView can perform a Redo action.
CanUndo Returns a Boolean whether the TextView can perform an Undo action.
Clear Clears the text inside the TextView.
Copy Copies the selected text on the clipboard.
Cut Cuts the selected text on the clipboard.
CutAsPlainText Cuts the selected text as plain text.
GetBackgroundColor / SetBackgroundColor Gets or Sets the text background color.
GetBaselineOffset / SetBaselineOffset
(iOS 7 and later only)
Gets or Sets the text baseline offset. The baseline offset is identical to subscript and superscript.
GetBold / SetBold Gets or Sets the text bold.
GetFont / SetFont Gets or Sets the text font name and size.
GetFontSize / SetFontSize Gets or Sets the text font size.
GetForegroundColor / SetForegroundColor Gets or Sets the text color.
GetItalic / SetItalic Gets or Sets the text italic.
GetParagraphStyle / SetParagraphStyle Gets or Sets the text paragraph style.
GetPlainText / GetPlainTextRange Gets the plain text from the TextView, optionally specified by a text range.
GetRichText / GetRichTextRange

Depending on the data type (see Import and Export chapter)
Gets the rich text from the TextView, optionally specified by a range.
GetStrikethrough / SetStrikethrough Gets or Sets the text strikethrough style. The style can be a combination of a line style, pattern and / or grouped by word. The style is the same type used in the GetUnderline / SetUnderline functionality.
GetStrikethroughColor / SetStrikethroughColor
(iOS 7 and later only)
Gets or Sets the text strikethrough color.
GetStrikethrough / SetStrikethrough Gets or Sets the text strikethrough style. The style can be a combination of a line style, pattern and / or grouped by word. The style is the same type used in the GetUnderline / SetUnderline functionality.
GetStrikethroughColor / SetStrikethroughColor
(iOS 7 and later only)
Gets or Sets the text strikethrough color.
GetStrokeColor / SetStrokeColor Gets or Sets the text stroke color.
GetStrokeWidth / SetStrokeWidth Gets or Sets the text stroke width.
GetSubscript / SetSubscript
(iOS 7 and later only)
Gets or Sets the text subscript value offset. Can be combined with SetFontSize for a smaller font.
GetSuperscript / SetSuperscript
(iOS 7 and later only)
Gets or Sets the text superscript value offset. Can be combined with SetFontSize for a smaller font.
GetTextLength Returns the length of the text of a TextView.
GetUnderline / SetUnderline Gets or Sets the text underline style. The style can be a combination of a line style, pattern and / or grouped by word.
GetUnderlineColor / SetUnderlineColor
(iOS 7 and later only)
Gets or Sets the text underline color.
GetURL / SetURL
(iOS 7 and later only)
Gets or Sets the text URL. The URL is only clickable when the TextView Editable property is set to false.
GetValues Gets all values applied on the text.
Import / ExportData

Depending on the data type (see Import and Export chapter)
Functionality to import / export the rich text from / to a file.
ImportFromStream / ExportToStream

Depending on the data type (see Import and Export chapter)
Functionality to import / export the rich text from / to a memory stream.
InitializeValues Used to initialize the record with default values before passing it to the SetValues method.
Paste Pastes the text from the clipboard.
PasteAsPlainText Pastes the text from the clipboard as plain text.
Redo Redoes the previous action (only available for plain text).
Select Selects a specific range of text.
SelectAll Selects all the text in the TextView.
SetRichText

Depending on the data type (see Import and Export chapter)
Sets the rich text from a TextView, optionally specified by a range.
ToggleBold Toggles bold on the selected text.
ToggleItalic Toggles italic on the selected text.
ToggleUnderline Toggles underline on the selected text.
Undo Undoes the last action (only available for plain text).

Import and export of (rich) text

The TextView supports importing and exporting the rich text to a stream, to a file and to a string. Some of the import / export functionality has the capability of adding an additional parameter to export to a plain, RTF, RTFD or HTML formatted data. The values of this parameter are listed below and specify which data type is supported on which iOS version and if import / export are supported:

DataType Supported iOS version Import / Export
dtArchivedXMLDocumentType iOS 6 and later TMSFMXNativeUIRichTextView
dtPlainTextDocumentType iOS 7 and later only TMSFMXNativeUIRichTextView
dtRTFTextDocumentType iOS 7 and later only TMSFMXNativeUIRichTextView (no image support)
dtRTFDTextDocumentType iOS 7 and later only TMSFMXNativeUIRichTextView
dtHTMLTextDocumentType iOS 7 and later only Export only