rvico TRichView Reference | Overview

RichView Hypertext Overview

Top  Previous  Next

TRichView has no default actions on hypertext events. However, it provides a convenient way for you to create hypertext document and define any actions that you want in response on user click on documents. RichView provides visual effects for items-hypertext links (highlighting).

There are the following types of hypertext items:

text of hypertext styles;

tabs and label items, linked to hypertext styles;

hot pictures

hotspots

RichView provides the following indication of hypertext items (when the mouse pointer moves above them):

changing color of text items (TFontInfo.HoverColor, HoverBackColor);

underlining text items (TFontInfo.HoverEffects);

changing mouse cursor (any hypertext text style can have its own cursor, see TRVStyle.JumpCursor, TFontInfo.JumpCursor)

for hotspots it can change picture (there are two pictures for hotspot "normal" and "hot"; they must be in the same imagelist but can have different indices);

By default, main events of hypertext (OnRVMouseMove, OnJump) and cursor indication do not work in editor (TRichViewEdit). Instead of highlighting items under mouse pointer editor highlights the item at the position of caret (item that is being edited).

But editor can be switched to hypertext mode when user presses and holds  Ctrl  key, if rvoCtrlJumps is in EditorOptions.

Since version 1.6, hypertext works in ReadOnly editor just like in viewer (since version 13, this behavior can be turned off using rvoNoReadOnlyJumps option from EditorOptions)

Besides, you can provide some specific actions in response on user clicking any RichView item, using OnRVMouseDown and OnRVMouseUp events.

Hypertext

Any hypertext link (text, hotspot or hot picture) has its own id. This id is passed in hypertext events - OnRVMouseMove and OnJump. The first hypertext item has id equal to RichView.FirstJumpNo, the next one is greater by one and so on. By default, RichView.FirstJumpNo=0 and hypertext items have id = 0, 1, 2, ...

Use OnRVMouseMove to provide action when user moves cursor to hypertext link. For example, you can change text in the status bar.

hmtoggle_arrow1Example

Special value (-1) is passed to this event as id when the user moves the mouse pointer outside any hypertext link. This event never occurs with the same id two times one after one.

The main hypertext event is OnJump.

hmtoggle_arrow1Example

The method shown in the example above (using id for defining specific actions) was the only available method in the older versions of RichView. Now you can use other ways, described below.

Sometimes information contained in the clicked item is enough to know what to do. The key method here is GetJumpPointLocation This function allows you to obtain the index of the clicked item. For example, if you have only text links (no hotspots and hot pictures) and they are URLs, you can write:

hmtoggle_arrow1Example

In the example above, we use GetJumpPointLocation to get the document containing this hyperlink (RVData) and the index of the clicked hypertext item in this document (ItemNo).

Next, we get information about the clicked text item with GetItemText and use the received string to launch a browser.

If you have both text and hotspot/hot pictures hypertext items, you can use RVData.GetItemStyle method to recognize the item type ("style"), and next use GetTextInfo or GetHotspotInfo/GetPictureInfo. For hotspots you can use image indices and hotspot name to decide which action to do.

The method shown in the next example is universal. You can use tags to add your information to any RichView item. (See tags).

hmtoggle_arrow1Example

Inserted controls cannot be hyperlinks. But, of course, you can set your own cursors and mouse events for any inserted control.

Hypertext and tables

Hypertext works not only in a the main document but also in table cells (subdocuments)

Hypertext links are numbered sequentially through the document, including links in cells. All links in the document have unique indices (id).

If you have a hypertext id you can obtain the hypertext item location with the method:

procedure TRichView.GetJumpPointLocation(id: Integer;

  var RVData: TCustomRVFormattedData; var ItemNo: Integer);

A hypertext item is the ItemNo-th item in RVData object.

RVData can be RichView[Edit].RVData, cell, or RVData of inplace editor.

Method GetJumpPointItemNo is obsolete because it returns only ItemNo.

See also...

OnReadHyperlink, OnWriteHyperlink;

example how to create a list of hyperlinks and move the caret to the selected hyperlink: http://www.trichview.com/forums/viewtopic.php?t=397.


TRichView © trichview.com