Type new text adjacent to a visible bookmark

  • Hello. I am currently converting an app using WPTools v3 to v6 and the conversion is going nicely.

    We previously used visible bookmarks to mark places in the document editor. The user could hotkey from bookmark to bookmark, entering text next to the bookmark. Bookmarks typically remained in the document but only visible while editing.The new text typed adjacent the the bookmarks would be normal text leaving the bookmark as it was.

    The bookmarks could be deleted (with backspace), But only inserted via menu command.
    The bookmarks contain one visible character ‘^’ and are surrounded with the usual bkmkstart\bkmkend tags in the file.

    However, in the new WPTools v6 We’re having difficulty keeping new text from writing inside the start\end tags. The contents of the bookmarks ‘^’ expand with the new text.
    We want the Bookmarks ‘^’ to be deleted like any other character. But don’t want thee bookmark text expanded when new normal text is typed adjacent to them.

    Our previous methods worked well in this regard but the changes have made it difficult to refactor.

    Can you provide any guidance?

    Here is how we achieved this behavior in WPTools 3.

    Code
    procedure TRTFEditor.OnKeyPressEvent(Sender: TObject; var Key: char);
    begin
        if afsBookmark in CurrAttr.Style then // prevent bookmark attribute from continuing beyond bookmark
        begin
          BeginUpdate;
          CurrAttr.DeleteStyle([afsBookmark]);
          EndUpdate;
        end;
    end;


    Regards,

    • Offizieller Beitrag

    In V3 the bookmarks were just a character attribute flag - now they are objects (start/end markers as they should be)

    You can use the property ProtectedProp to protect the text INSIDE the bookmarks, so text cannot be entered there. It should be possible to replace the bookmarks "on the fly" with singular text objects. If you need help here, please send e-mail.

    BTW - if you do the work to go from V3 to V6 I would recommend to go to WPTools V7 directly. It wont be any more difficult and you get the latest support.