|
RichView Items' "Tags" Overview |
Top Previous Next |
|
Each item of RichView has an associated integer value – tag. Tags are provided for the convenience of storing additional integer value (4 bytes) or pointer information for special needs in application. Moreover, RichView can work in mode where all tags are treated as PChar – pointers to dynamically allocated strings. The main purpose of tags is organizing work with hypertext. Do not confuse RichView items tags with "Tag" properties of TComponent descendants! (RichView uses "Tag" properties of inserted controls for its own needs; you can set "Tag" properties of ImageList for organizing saving/loading "bullets" and "hotspots" from RVF; but this topic is about completely another tags!) What you need to know about items tags:
"Tags are PChars mode" In this mode RichView:
When RichViewEdit needs to duplicate tags (for example when user press Enter key and the current line will be separated into two lines) the editor duplicates it by allocating the same string (using StrNew) so both new items will have their own tag strings. There are some rules for using components in this mode:
For example MyRichView.AddNLTag('Example', 0, 0, Integer(StrNew('Tag Example')));
Do not confuse StrNew with NewStr. Do not use NewStr! The same rule applies to InsertStringTag and InsertStringWTag of TRichViewEdit.
Example: var Tag: Integer; S: String; TagStr: PChar; // Converting the first text item and its tag string to upper case MyRichView.GetTextInfo(0, S, Tag); TagStr := StrNew(PChar(Tag)); TagStr := StrUpper(TagStr); MyRichView.SetItemText(0, UpperCase(S)); MyRichView.SetItemTag(0, Integer(TagStr));
See also... RichView methods for adding items with tags to the end of document: AddNLTag, AddTag, AddBreakTag, AddPictureExTag, AddHotspotExTag, AddBulletExTag, AddControlExTag, AddBreakExTag. RichView methods for adding "checkpoints" with tags to the end of document: AddCheckpointTag, AddNamedCheckpointExTag. RichView methods for obtaining information about items (including tags): GetItemTag, GetBreakInfo, GetBulletInfo, GetHotspotInfo, GetPictureInfo, GetControlInfo, GetTextInfo. RichView methods for modifying items (including tags): SetItemTag, SetBreakInfo, SetBulletInfo, SetHotspotInfo, SetPictureInfo, SetControlInfo. RichView methods allowing work with checkpoints tags: FindCheckpointByTag, GetCheckpointInfo, SetCheckpointInfo. RichViewEdit methods for obtaining information about item in caret position: GetCurrentTag, GetCurrentBreakInfo, GetCurrentBulletInfo, GetCurrentHotspotInfo, GetCurrentPictureInfo, GetCurrentControlInfo, GetCurrentTextInfo. RichViewEdit methods for inserting: InsertStringTag, InsertStringWTag. RichViewEdit methods for modifying items (including tags): SetItemTagEd, SetBreakInfoEd, SetBulletInfoEd, SetHotspotInfoEd, SetPictureInfoEd, SetControlInfoEd. RichViewEdit methods for modifying information about item in caret position: SetCurrentTag, SetCurrentBreakInfo, SetCurrentBulletInfo, SetCurrentHotspotInfo, SetCurrentPictureInfo, SetCurrentControlInfo RichViewEdit methods for working with checkpoints tags: SetCheckpointInfoEd, SetCurrentCheckpointInfo. RichViewEdit options affecting tags: |