hyperlink TrvActionInsertHyperlink

Properties   Methods   Events

Top  Previous  Next

TrvActionInsertHyperlink is the action for "Insert | Hyperlink" command.

Unit RichViewActions;

Syntax

TrvActionInsertHyperlink = class(TrvActionTextStyles)

hmtoggle_arrow1Hierarchy

Description

This action can perform the following tasks:

inserting a new text hyperlink, with the specified target and text;

converting the selected text and (optionally) pictures to hyperlinks (with the specified target);

removing hyperlink from the selected fragment.

When this action is executed, it displays a dialog for defining hyperlink attributes. But before the dialog is shown, the action adjusts the selection in TCustomRichViewEdit: if the selection includes a hyperlink partially (or if there is no selection but the caret is inside a link), this hyperlink is selected completely. If the selection is still empty, the action will insert a new hyperlink. Otherwise it will convert the selected fragment to hyperlinks (or will change targets for existing hyperlinks in the selection). If the user will enter an empty target, all links will be removed instead.

By default, the action stores targets of hyperlinks in items' tags. You can override this behavior using OnApplyHyperlinkToItem and OnGetHyperlinkTargetFromItem events.

Using style templates

Visual appearance of a hyperlink depends on whether style templates are used.

If style templates are not used: the action allows defining text and background colors for hyperlinks (including "hover" colors). The chosen colors will be applied to all new links. When converting a text to a hypertext, properties listed in ValidProperties are applied to its style (and the original style is assigned to its NextStyleNo property).

When converting a hypertext to a text, the same set of properties are changed. But instead of properties of this action, properties of RVStyle.TextStyles[0] are applied (and -1 is assigned to NextStyleNo property).

The dialog window has a button invoking a new dialog for changing the link color.

If style templates are used: the action applies StyleTemplateName to hyperlinks. When converting a hypertext to a text, the action clears a link to style template.

The dialog window has a combo-box allowing to choose a style template. Only style templates having Kind=rvstkText are listed.

Methods

In addition to the operations performed on the execution, the action has several useful methods:

GetHyperlinkStyleNo returns the index of hypertext style for the given text style;

GetNormalStyleNo returns the index of non-hypertext style for the given text style;

DetectURL analyses text to the left of the caret; if it is URL, converts it to hyperlink;

TerminateHyperlink converts the current text style to non-hypertext, if the caret is at the end of hyperlink;

GoToLink opens the hyperlink target in the external browser; for local links, it moves the caret to the target checkpoint.

 

   


RichViewActions © trichview.com