Show wpobjCustom tags?

  • I know you can show codes for some objects like wpobjBookmark and wpobjHyperlink using the wpShowBookmarkCodes and wpShowHyperlinkCodes properties, but I don't see an option to show the wpobjCustom codes. I believe in the past (v4 I think) you once told me the wpobjCustom object is not designed to be used in pairs, but it seems to be usable that way in v8. So, I'd like to be able to show the user where these codes are embedded in the text like I can for those other wpobj's, i.e. to be able to see the [c] and [/c] codes.

    I looked in the source and don't see that it is implemented for that object. Any chance you could provide this as an option in a future update?

    Kind of on the same subject, is there a way to know when a wpobj pair gets deleted? I'd like to be able to do something to the text between the start/end codes of a wpobj when the codes get deleted. So an OnBeforeWpObjDeleted event would be sweet (the onBefore event would allow me to easily change the range of text before the codes go away).

    Thanks,

    Eric

    • Offizieller Beitrag

    using OnTextObjectPaint it should be possible to also paint this objects.

    There is no event for the deletion of an objects, other than the OnDestroy event of the TWPTextObj itself. But note, objects can be destroyed at any time due to the way paragraphs work. Think of the case the user presses enter and splits a paragraph into two.

    Whatever it is - I would consider against using wpobjCustom.

  • Unless you can some up with something better for me, I need three object types:

    1. Bookmarks - we use to show linked text that will be brought into a auto-summary section of a generated report, and also to create user bookmarking for a user table of contents (like an image TOC) separate from the basic TOC which just lists chapters and topics.

    2. Hyperlinks - We use for in-line drop down string builder and to maintain the important WYSIWYG experience and for in-line checkbox toggling.

    3. ??? - use to mark cloakable text. A single click will toggle text/images/etc (everything between the tags as being marked for deletion or not when the report is created.

    We have been using the hyperlink for #3, but this causes painting issues of the attributes. For example, if we have a picklist inside of cloakable text with both using Hyperlinks, and we mark a picklist using a double blue underline, and cloakable text with a single gray underline and toggle the text gray/black depending on if it is cloaked or not, then everything past the picklist does not get the gray underline or gray text causing it to look to the user as if it is not cloaked even though it could be.

    If we change the cloakable text to use bookmarks, then we have the same issue if cloakable text is inside linked text which also uses bookmarking. In other words, if two of the same object type has one inside the other, then attribute painting stops showing to the right after the embedded one.

    I can make cloakable text use the Hidden attribute settings which solves the attribute painting issue except I need something to tell me if it is cloaked or not and to be able to click on it to toggle it. So I use the Source property of the object to indicate this and to tell how to paint the text contained between the tags, i.e gray or black. The tags also tell me what I can delete which might include images when generating the report. Using the wpobjcustom tags seems to give me what I want except I cannot easily remove the hidden attribute should one of the wpobjcustom tags get deleted. I think I'd have to scan the whole body looking for chars with the hidden attribute that is not within wpobjcustom tags. But when to do that efficiently is also questionable.

    So basically I need just one more tag pair like hyperlink and bookmarking with properties that I can set to change color etc without having to resort to using an unrelated attribute such as afsHidden.

    I thought about using Span, but not available with RTF (at least it does not appear to work and I saw in the documentation that it is only for HTML).

    I also contemplated modifying your code to add my own tag, but that would be horrible to maintain with WPTools updates.

    Anyway, that's where I'm at.

    • Offizieller Beitrag

    Hi,

    I would use fields for #3, wpobjMergeFields. You can even process that text inside the OnMailMergeGetText event. (But any paired object can be used for mail merge, thats a specialty of wptools which is rarely recognized)

    if you need the fields somewhere else, you can use wpobjTextProtection. But note that they are not saved or loaded in RTF format.

  • Good idea. I was avoiding the wpobjMergeField because we support both normal text entry and what we call field entry mode, so we do use fields. However I like the way I can use the wpobjMergeField over the use of wpobjCustom/afsHidden since I don't have to worry about the hidden attribute. Since we won't need to allow cloakable text in a field entry form, I may be able to work with this since I will know what type is loaded into the TWPRichText as to if it is field entry type or not. Making it a dual purpose object.

    Einmal editiert, zuletzt von ehimmer (20. Februar 2019 um 16:35)

  • I think found two bugs:

    1) If I set the wpobjMergeField Source property, saving and restoring puts it into the Name property instead. I lose the Source property.

    2) When hiding the insert points, the end point still appears as a space.

  • 1) No problem, I can use the Name property, however, your documentation seems to imply that Source is used:

    http://www.wpcubed.com/manuals/wptool…eld_display.htm

    WPRichText1.InsertPointAttr.CodeOpeningText := '[%N=';

    // %N inserts the TWPTextObj.Name property

    // %S inserts the TWPTextObj.Source property

    // %Y inserts the TWPTextObj.StyleName property - only useful for span styles

    // %P inserts the TWPTextObj.Params property


    2) Yes, InsertPointAttr.Hidden = false. When True, I see the insert point and there is no space, just the insert end point. When false, the endpoint text is replaced with a space character unlike the start point which is as expected, hidden/gone. The endpoint is an actual space char, the width should no matter since it is supposed to be hidden. I cannot have this space char since it violates WYSIWYG. People are going to try to delete that space and end up deleting the field object.

    Example:

    When insertPointAttr.Hidden := false:

    abc<defg>hijk

    When true:

    abcdefg hijk

    Should be:

    abcdefghijk

  • I took a look at OnTextObjGetTextEx, and WidthInPix is always -1 with the PrintString being the actual start/end point characters. I tried setting the PrintString to an empty string and that resolved it. But still wouldn't think I should have to do that when I've set InsertPointAttr.Hidden to true.

    2 Mal editiert, zuletzt von ehimmer (20. Februar 2019 um 17:43) aus folgendem Grund: Checked obj type incorrectly on OnTextObjGetTextEx in initial testing.

    • Offizieller Beitrag

    I understand, however there is another property or event involved. InsertPoint.Hidden always removed the start and end point.

    Do you call ReformatAll?

    Code
    begin
      Fieldmarker1.Checked := not Fieldmarker1.Checked;
      WPRichText1.InsertPointAttr.Hidden := not Fieldmarker1.Checked;
      WPRichText2.InsertPointAttr.Hidden := not Fieldmarker1.Checked;
      WPRichText1.ReformatAll(true,true);
    end;
  • Hidden is currently always set to true at the moment and I even set it to true when loading the WPRichText from data form the databse, and it will always show a space for the end tag. I added the ReformatAll as you show, and it makes no difference. I seem to have to set PrintString to an empty string for the end tag.

    This is what I have to do in OnTextObjGetTextEx:

    Code
    if TXTObject.ObjType = wpobjMergeField then
      begin
        if pWPRichText.InsertPointAttr.Hidden and
          (TXTObject.IsEndTag) and (TXTObject.StartTag <> nil) and
          (Pos('$cloak:', TXTObject.StartTag.Name) = 1)
        then
          PrintString := '';
        exit;
      end;

    Einmal editiert, zuletzt von ehimmer (20. Februar 2019 um 18:25) aus folgendem Grund: Added example code