TCustomRichViewEdit.OnDrawCustomCaret [VCL and LCL]

<< Click to display table of contents >>

TCustomRichViewEdit.OnDrawCustomCaret [VCL and LCL]

Allows to draw a custom caret.

type

  TRVDrawCustomCaretEvent = procedure (Sender: TCustomRichViewEdit;

    Canvas: TCanvas; const Rect: TRVCoordRectof object;

property OnDrawCustomCaret: TRVDrawCustomCaretEvent;

(introduced in version 10)

Custom caret is drawn if CustomCaretInterval>0.

OnMeasureCustomCaret event occurs before each call of this event.

Example

This example draws a rectangle/ellipse caret. In combination with the example in OnMeasureCustomCaret topic, it draws rectangle/ellipse around the character to the right of the caret.

procedure TMyForm.MyRichViewEditDrawCustomCaret(

  Sender: TCustomRichViewEdit;

  Canvas: TCanvas; const Rect: TRVCoordRect);

const f: Boolean=True;

var r: TRVCoordRect;

begin

  if f then

    Canvas.Pen.Color := clRed

  else

    Canvas.Pen.Color := clBlue;

  f := not f;

  r := Rect;

  Canvas.Brush.Style := bsClear;

  if f then

    Canvas.Rectangle(r)

  else

    Canvas.Ellipse(r);

end;