<< Click to display table of contents >> TRichView Clipboard Functions Overview |
TCustomRichView and its descendants can copy information to the Clipboard as a plain text, an image, RTF and RVF, Markdown, and your own custom formats.
TRichViewEdit can paste information from the Clipboard as text (ANSI and Unicode), image, RTF, HTML, RVF, URL, file (and your own formats).
The main method for copying to the Clipboard is CopyDef. It can copy selection in one or more formats.
This method copies data in formats specified in TRichView.Options:
Option |
Meaning |
---|---|
rvoAutoCopyText |
if set, CopyDef copies selection as ANSI text |
rvoAutoCopyImage |
if set, CopyDef can copy selected image to clipboard |
rvoAutoCopyUnicodeText |
if set, CopyDef copies selection as Unicode text |
rvoAutoCopyRTF |
if set, CopyDef copies selection as RTF (Rich Text Format) |
rvoAutoCopyRVF |
if set, CopyDef copies selection as RVF |
CopyDef is called automatically when the user presses Ctrl + Insert or Ctrl + C .
You can also use methods for copying:
▪Copy copies selection to the Clipboard in all formats;
▪CopyTextA copies the selection as ANSI text (deprecated; Windows only);
▪CopyTextW copies selection as Unicode text
▪CopyImage – if there is a selected image, this method copies it to the Clipboard;
▪CopyRVF copies selection in RVF format. This format has name 'RichView Format' and consist of two parts: <Size of RVF><RVF> where <Size of RVF> is 4-byte integer value (number of bytes in <RVF>), <RVF> is RVF data (see: About RVF, RVF Specification)
▪CopyRTF copies selection as RTF (Rich Text Format).
▪CopyMarkdown copies selection as Unicode text in Markdown format.
SelectionExists method answers to the question "does the selection contain some data (not empty)?"
OnCopy event allows copying in your own formats.
In FireMonkey for mobile platforms, only one format can be copied to the Clipboard. Copy and CopyDef work identically: they copy the most appropriate format from the formats listed in rvoAutoCopy* Options.
The options rvoAutoCopyText and rvoAutoCopyUnicodeText work identically: Unicode text is copied.
TRichView cannot paste. All these methods are methods of TRichViewEdit.
Pasting:
▪PasteBitmap pastes bitmap from the Clipboard, if available;
▪PasteMetafile pastes metafile picture from the Clipboard, if available [VCL];
▪PasteGraphicFile pastes graphic file(s) the Clipboard, if available [Windows];
▪PasteText pastes text from the Clipboard, if available;
▪PasteRVF pastes RVF from the Clipboard, if available;
▪PasteRTF pastes RTF from the Clipboard, if available;
▪PasteHTML pastes HTML from the Clipboard, if available;
▪PasteURL pastes URL from the Clipboard, if available [Windows];
▪Paste tries to paste as an RVF; if cannot – as an RTF, if cannot – as HTML, if cannot – as an URL, if cannot – as a text; if cannot – as graphic file(s), if cannot – as a bitmap; if cannot – as a metafile. AcceptPasteFormats property is taken into account. This method is called automatically when user press Ctrl + V or Shift + Insert .
▪PasteMarkdown pastes text from the Clipboard as Markdown, if available.
Testing is the Clipboard has the specific format:
▪CanPaste – "does the Clipboard contain any format what can be pasted in RichViewEdit?"
▪CanPasteRVF – "does the Clipboard contain RVF?"
▪CanPasteRTF – "does the Clipboard contain RTF?"
▪CanPasteHTML – "does the Clipboard contain HTML?"
OnPaste event allows to override the default pasting procedure. For example, you can paste data in different format, or you can allow pasting only some specific formats (for example, only a plain text).
RichViewEdit.CutDef copies the selection (like CopyDef) and then deletes it (like DeleteSelection). This method is called automatically when user presses Ctrl + X or Shift + Delete .
RichView processes WM_COPY message, RichViewEdit also processes WM_PASTE, WM_CUT, EM_CANPASTE.