Hyperlink Basic Functions
Hyperlink Basic Functions
Is there any new and simple to implement for this basic functions for hyperlink? Add, Remove, Update and Detect if is is a hyperlink in RichViewEdit? Thanks in advance.
-
- Site Admin
- Posts: 17805
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Hyperlink Basic Functions
At their core, hyperlinks are items within a document. Possible options include:
The simplest examples of creating a document with hyperlinks and handling clicks on them (in the OnJump event) can be found in the second group of Tutorial projects for TRichView.
- If it is a text item, it must be associated with a text style that has the property Jump = True.
- If it is a non-text item that is still associated with a text style (such as a label, footnote, etc.), then similarly, the text style must have the property Jump = True.
- There are certain items that are hyperlinks by themselves, in particular the hot-picture item.
The simplest examples of creating a document with hyperlinks and handling clicks on them (in the OnJump event) can be found in the second group of Tutorial projects for TRichView.
-
- Site Admin
- Posts: 17805
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Hyperlinks in RichViewActions
Hyperlinks in RichViewActions
The easiest way to work with hyperlinks is by using RichViewActions. The main commands for inserting and editing links are implemented in the TRVActionInsertHyperlink action. When this action is executed, a dialog window appears where you can set the properties of a new link or modify an existing one—including removing it by entering an empty target. It also supports links to positions within the current document; just like in HTML, such links start with the # character.
The appearance of a hyperlink depends on whether "real" (named) styles—StyleTemplates—are being used. If Editor.UseStyleTemplates = True, the appearance of hyperlinks should be defined in the style named "Hyperlink". Otherwise, the color and other formatting of the hyperlink text are set in the properties of TRVActionInsertHyperlink, and can also be changed by the user in a special dialog window, which can be opened from the insert/edit hyperlink dialog.
To follow a hyperlink, call the rvActionInsertHyperlink.GoToLink method in the OnJump event. It can open URLs and files, or scroll to a position within the document.
rvActionInsertHyperlink has the methods DetectURL and TerminateHyperlink, which should be called from text input events. DetectURL automatically creates hyperlinks from URLs on typing, while TerminateHyperlink switches the current style from hyperlink to regular text when the user types a character that ends the link (such as a space).
TRVActionInsertHyperlink has several other useful methods as well.
And finally, TRVActionRemoveHyperlinks removes all hyperlinks from the selected text.
The easiest way to work with hyperlinks is by using RichViewActions. The main commands for inserting and editing links are implemented in the TRVActionInsertHyperlink action. When this action is executed, a dialog window appears where you can set the properties of a new link or modify an existing one—including removing it by entering an empty target. It also supports links to positions within the current document; just like in HTML, such links start with the # character.
The appearance of a hyperlink depends on whether "real" (named) styles—StyleTemplates—are being used. If Editor.UseStyleTemplates = True, the appearance of hyperlinks should be defined in the style named "Hyperlink". Otherwise, the color and other formatting of the hyperlink text are set in the properties of TRVActionInsertHyperlink, and can also be changed by the user in a special dialog window, which can be opened from the insert/edit hyperlink dialog.
To follow a hyperlink, call the rvActionInsertHyperlink.GoToLink method in the OnJump event. It can open URLs and files, or scroll to a position within the document.
rvActionInsertHyperlink has the methods DetectURL and TerminateHyperlink, which should be called from text input events. DetectURL automatically creates hyperlinks from URLs on typing, while TerminateHyperlink switches the current style from hyperlink to regular text when the user types a character that ends the link (such as a space).
TRVActionInsertHyperlink has several other useful methods as well.
And finally, TRVActionRemoveHyperlinks removes all hyperlinks from the selected text.
-
- Site Admin
- Posts: 17805
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Hyperlinks without RichViewActions
Hyperlinks without RichViewActions
If you don't want to use RichViewActions (or can't, for example because you're working with FireMonkey, where RichViewActions are not yet implemented), take a look at the demo projects in the TRichView\Demos\*\Assorted\Hypertext\ folder.
CreateHyperlink demonstrates how to create a new hyperlink, change its target, or remove an existing one. It has a limitation—it works only with text items.
The URLs demo shows how to detect URLs while typing, find URLs in existing text, and modify link targets during editing. It includes a useful URLScan.pas unit that you can incorporate into your own application.
If you don't want to use RichViewActions (or can't, for example because you're working with FireMonkey, where RichViewActions are not yet implemented), take a look at the demo projects in the TRichView\Demos\*\Assorted\Hypertext\ folder.
CreateHyperlink demonstrates how to create a new hyperlink, change its target, or remove an existing one. It has a limitation—it works only with text items.
The URLs demo shows how to detect URLs while typing, find URLs in existing text, and modify link targets during editing. It includes a useful URLScan.pas unit that you can incorporate into your own application.
-
- Site Admin
- Posts: 17805
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Plans
Plans
I’m planning to create a new component to simplify document editing—providing an easy-to-use interface for working with text and paragraph attributes, hyperlinks, and tables. For VCL, it will serve as a lightweight alternative to RichViewActions; for FireMonkey, it will be the foundation for future RichViewActions FMX.
I’m planning to create a new component to simplify document editing—providing an easy-to-use interface for working with text and paragraph attributes, hyperlinks, and tables. For VCL, it will serve as a lightweight alternative to RichViewActions; for FireMonkey, it will be the foundation for future RichViewActions FMX.