GoToItem.pas includes functions for moving the caret to the next/previous item meeting the specified criteria. The caret is moved to the end of the found item (the item can be selected optionally).
The functions return True if moving was successful (False if the item was not found in the given direction). The search is started from the current item (i.e. the item containing the caret).
Moving the caret to the next/previous hyperlink:
function GoToNextHyperlink(rve: TCustomRichViewEdit; Select: Boolean=False): Boolean;
function GoToPrevHyperlink(rve: TCustomRichViewEdit; Select: Boolean=False): Boolean;
Moving the caret to the next/previous item of one of the specified types:
function GoToNextItem(rve: TCustomRichViewEdit; ItemTypes: array of Integer; Select: Boolean=False): Boolean;
function GoToPrevItem(rve: TCustomRichViewEdit; ItemTypes: array of Integer; Select: Boolean=False): Boolean;
Example (moving to the next picture):
Code: Select all
GoToNextItem(rve, [rvsPicture, rvsHotPicture])
function GoToNextItemEx(rve: TCustomRichViewEdit; UserData: Pointer; Func: TCheckItemFunction; Select: Boolean=False): Boolean;
function GoToPrevItemEx(rve: TCustomRichViewEdit; UserData: Pointer; Func: TCheckItemFunction; Select: Boolean=False): Boolean;
UserData parameter is passed to Func.
Func is a function for checking items. It must return True if RVData.GetItem(ItemNo) is ok (i.e. the caret should be moved to it).
type TCheckItemFunction = function (RVData: TCustomRVData; ItemNo: Integer; UserData: Pointer): Boolean;
Example (moving to the next text having a colored background):
Code: Select all
function IsColoredText(RVData: TCustomRVData; ItemNo: Integer;
UserData: Pointer): Boolean;
var StyleNo: Integer;
begin
StyleNo := RVData.GetItemStyle(ItemNo);
Result := (StyleNo>=0) and (RVData.GetRVStyle.TextStyles[StyleNo].BackColor<>clNone);
end;
...
GoToNextItemEx(RichViewEdit1, nil, IsColoredText);