TextObject.OnDestory and SelectAll

  • I assign an OnDestroy event to image TextObjects to occur when deleting an image in order to do some house cleaning. Deleting a selected image works, even selecting text that includes all the images (but not all the text) works. However, if I do a SelectAll (Ctrl+A) or use the mouse select everything and hit the delete key, the OnDestroy for the images is not being invoked. Any idea what is wrong?

    WPRichText 9.1.820

    Delphi 10.4.1

  • Sorry, not sure I understand. Take for example a WPRichText with many paragraphs and about 10 linked images. I can select everything except one word, and hit the DEL key, and all images get their OnDelete event triggered. However, if I select ALL text, they do not trigger their OnDelete event.

    Einmal editiert, zuletzt von ehimmer (31. Oktober 2020 um 16:48)

  • My bad, yes, OnDestroy in which I set the event to my ImageDeleted procedure. So why the difference if I select all vs select most followed by the DEL key? I don't do anything different, but does deleting all go thru a different path? I really need to know when an image gets deleted by any method. So for now in the case when everything was deleted, I have to use the WPRichText's OnChange event and if it is empty I loop thru all ImageObjects (I keep a list of them for purposes like this), and in code I force a call to my ImageDeleted function which gets me by. I don't like that, but if that is what I have to do, then that is what I have to do. I still don't understand why Select all + DEL is not doing the same thing as Select some/most + DEL in regards to OnDestroy since they are being destroyed in both instances. If it has to do with the Undo buffer, why do they not both do the same thing?

    2 Mal editiert, zuletzt von ehimmer (1. November 2020 um 20:29)

    • Offizieller Beitrag
    Code
    So why the difference if I select all vs select most followed by the DEL key?

    ... when editing the text because text objects are destroyed and only copies are created in the undo buffer.

    But when you delete selected text whole paragraphs are sent to the undo buffer, including the original objects.

    That's all for performance reasons. It does not make sense to create a copy if a full paragraph is deleted.

    I check if I can make an option in next version for You

  • I don't mean to be a pain, but I do select multiple whole paragraphs and the hit the DEL key and the OnDestroy event does get invoked. But if I select ALL paragraphs it does not invoke the OnDestroy event. This is why I ask what the different is.