Trichview.addtag(str,i,i);
,
how to remove it when click?
how to remove Tag
I guess you'd use RichView.SetItemTag(ItemNumber, TagValue).
You must figure out what the Item number is (when it's clicked as you mentioned - or whenever).
As far as "removing" it, I don't think you can do that in the strict sense of the word. A RichView Tag is just an integer property of every Item, so you can just reset it to zero using the above function.
Note that when TagsArePChars, you can remove the pointed-to string (again, by passing zero), but your Tag doesn't look like a PChar kind, so this is not likely to be relevant.
Hope this helps,
Michel
You must figure out what the Item number is (when it's clicked as you mentioned - or whenever).
As far as "removing" it, I don't think you can do that in the strict sense of the word. A RichView Tag is just an integer property of every Item, so you can just reset it to zero using the above function.
Note that when TagsArePChars, you can remove the pointed-to string (again, by passing zero), but your Tag doesn't look like a PChar kind, so this is not likely to be relevant.
Hope this helps,
Michel
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
In any cases (tags are PChars or not), "removing tag" can be done by assigning 0 to it.
Code for removing tag on clicking:
The code above can be used both for TRichView and TRichViewEdit. It cannot be undone/redone by user. If you need to make it undoable (only for TRichViewEdit):
Code for removing tag on clicking:
Code: Select all
// RichViewEdit1.OnRVMouseMove
procedure TForm3.RichViewEdit1RVMouseUp(Sender: TCustomRichView;
Button: TMouseButton; Shift: TShiftState; ItemNo, X, Y: Integer);
var LRVData: TCustomRVFormattedData;
LItemNo, LOffs: Integer;
LPoint: TPoint;
begin
if (Button<>mbLeft) or Sender.SelectionExists then
exit;
LPoint := Sender.ClientToDocument(Point(X, Y));
if not Sender.GetItemAt(LPoint.X, LPoint.Y, LRVData, LItemNo, LOffs, True) then
exit;
LRVData.SetItemTag(LItemNo, 0);
end;
Code: Select all
procedure TForm3.RichViewEdit1RVMouseUp(Sender: TCustomRichView;
Button: TMouseButton; Shift: TShiftState; ItemNo, X, Y: Integer);
var LRVData: TCustomRVFormattedData;
LItemNo, LOffs: Integer;
LPoint: TPoint;
begin
if (Button<>mbLeft) or Sender.SelectionExists then
exit;
LPoint := Sender.ClientToDocument(Point(X, Y));
if not Sender.GetItemAt(LPoint.X, LPoint.Y, LRVData, LItemNo, LOffs, True) then
exit;
LRVData := TCustomRVFormattedData(LRVData.Edit);
RichViewEdit1.SetItemTagEd(LItemNo, 0);
end;