We make use of item tags (SetItemTag) to store a label for a line/block of text (and display this to the left of the paragraph on draw). When a new paragraph is started this item tag is carried forward (by the looks of it) to the new paragraph showing the same tag on the left of that paragraph.
Is there n approach to a) catch the new paragraph event (with enough detail to change the tag values) or b) a property that will prevent the tags from being carried forward or c) another approach entirely.
Thanks.
Prevent ItemTags from continuing to next paragraph
-
- Posts: 7
- Joined: Sat Jun 20, 2015 7:03 am
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Unfortunately, copying tags for new items on Enter is hard-coded.
If a text on the new line has the same style as the text on the original line, the tag is copied. Otherwise, it is cleared.
I can add an option to clear it regardless of the style change. Would it be sufficient? Do you think that tags should be cleared when pressing Enter both in the beginning and in the end of the paragraph?
If a text on the new line has the same style as the text on the original line, the tag is copied. Otherwise, it is cleared.
I can add an option to clear it regardless of the style change. Would it be sufficient? Do you think that tags should be cleared when pressing Enter both in the beginning and in the end of the paragraph?
-
- Posts: 7
- Joined: Sat Jun 20, 2015 7:03 am
Thanks Sergey. I think an option to clear would work well. I guess our use case is if enter is pressed in the middle of a paragraph then the first part would retain the tag and the second would have it cleared. Something we need to add is an option in a context menu to clear/set the item tag.
I guess we are trying to use the tag for metadata about the paragraph. I'm not sure whether there is a better option for this currently.
I guess we are trying to use the tag for metadata about the paragraph. I'm not sure whether there is a better option for this currently.
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Well, the planned tag clearing option will work only when pressing Enter at the end and the beginning of a paragraph.
If Enter is pressed in the middle of a text item, you can use OnItemTextEdit event to change tags. As an example, you can see the demo in Demos\DelphiUnicode\Assorted\Hypertext\URLs\. It uses this event to remove/detect hyperlinks when editing.
But if your tags are specific for certain paragraphs, what if the user copies-pastes text?
If Enter is pressed in the middle of a text item, you can use OnItemTextEdit event to change tags. As an example, you can see the demo in Demos\DelphiUnicode\Assorted\Hypertext\URLs\. It uses this event to remove/detect hyperlinks when editing.
But if your tags are specific for certain paragraphs, what if the user copies-pastes text?
-
- Posts: 7
- Joined: Sat Jun 20, 2015 7:03 am
Understand. If enter is pressed at the start of the paragraph then would make sense for the tag to stay with the second paragraph - i.e. the part originally on and if at the end then stay with the first.
If pasted then quite probably the pasted text shouldn't hold on to tag information but if there is an event to catch this and remove the tag then it doesn't need to be tied to the option (though may be simpler if it was).
If pasted then quite probably the pasted text shouldn't hold on to tag information but if there is an event to catch this and remove the tag then it doesn't need to be tied to the option (though may be simpler if it was).