Hover Effects

<< Click to Display Table of Contents >>

Navigation:  Programming > User Interface > Modify the look and feel of the editor >

Hover Effects

 

Certain text can change the attributes when the mouse is moved over it. In addition a hint window can be displayed. This is useful for mail merge fields and hyperlinks.

 

All text which support this kind of interaction can also use global style and color definitions set up in these properties:

 

i)   property HyperlinkTextAttr: TCharacterAttrTags;

    property BookmarkTextAttr: TCharacterAttrTags;

    property SPANObjectTextAttr: TCharacterAttrTags;

    property AutomaticTextAttr: TCharacterAttr;

 

ii) property ProtectedTextAttr: TCharacterAttr;

    property HiddenTextAttr: TCharacterAttr;

 

iii) property FieldObjectTextAttr: TCharacterAttr ;

    property InsertPointAttr: TCharacterAttrTags;

 

The group i) defines attributes for texts which is wrapped in TWPTextObj instances of the following types: wpobjHyperlink, wpobjBookmark, wpobjSPANStyle and wpobjMergeField (= merged text).

 

The two prioperties in group ii) affects text which uses the character style afsProtected and afsHidden.

 

In group iii) FieldObjectTextAttr changes the appearance of wpobjTextObject objects (with the exception of objects with the name 'PAGE', 'NUMPAGES', 'SYMBOL'.

InsertPointAttr changes the way wpobjMergeField objects are displayed and can be used to hide those objects.

 

The TCharacterAttr class contains various properties to change the color of the "special" text, to add or remove underlines and to set the underline color.

 

To display hint windows two events can be used:

 

a) the OnActivateHint event

 

This event is triggered when the mouse is moved over special text which uses the property OnHintEventIsActive set to true in the respective TCharacterAttr property. Since there is no OnDeactivateHint event we suggest to use a timer to hide the window. In contrast to property "HotStyleIsActive" the property "OnHintEventIsActive" does not force a repaint of the text window!

 

a) the OnActivatingHotStyle event

 

This event is triggered when the mouse is moved over special text which uses the property HotStyleIsActive set to true in the respective TCharacterAttr property.

 

This code can be used to show a hint window with information about merged text. HotStyleIsActive must be set to TRUE in property AutomaticTextAttr:

 

procedure TForm1.WPRichText1ActivatingHotStyle(Sender: TObject;

 par: TParagraph; posinpar: Integer);

var p : TPoint;

begin

if par <> nil then

begin

    FHintForm.Caption :=

         (Sender as TWPCustomRTFEdit).FieldGetNameInPar(par,posinpar);              

         p := TWPCustomRTFEdit(Sender).GetPointFromParLin(par, posinpar);

    if p.x > TWPCustomRTFEdit(Sender).Width then

         p.x := TWPCustomRTFEdit(Sender).Width;

    p := TWPCustomRTFEdit(Sender).ClientToScreen(p);

    FHintForm.Left := p.x;

    FHintForm.Top := p.y;

    FHintForm.Show;

end;

end;

 

The hint form is hidden in event OnDeactivateHotStyle

 

procedure TForm1.WPRichText1DeactivateHotStyle(Sender: TObject);

begin

  FHintForm.Hide;

end;

 

If you need to use OnClick events for certain texts use the event OnClickHotText and the property ClickableCode. See previous chapter for more information.