RichTextBox - detect if document was changed

Posted by: s.khmaruk on 19 September 2018, 10:52 pm EST

    • Post Options:
    • Link

    Posted 19 September 2018, 10:52 pm EST

    What is the right way to detect if the document was changed.

    For example TextChanged event is firing when you just click “Delete” in an empty document, or when you just navigate by cursor buttons in the document (especially in the document with links and images).

    Html property also changes during navigation in the document.

  • Posted 19 September 2018, 10:55 pm EST

    Event is firing and Html property changes during navigation not always, only in rear cases but it does.

  • Posted 20 September 2018, 4:02 pm EST

    Hi Sergey,

    For this, you need to handle the TextChanged event only but inside take help of its e.Range.Text.Length && e.Action. Like, though pressing Delete key would trigger TextChanged event but its e.Action would be Reset different than when you press some character key which will result in e.Action= Add

    Thanks,

    Ruchir

  • Posted 20 September 2018, 5:16 pm EST

    As I sad before, try to navigate in the document with cursor buttons.

    For example:

    Create empty document.

    Add link with Text “1” and URL “1”.

    Press Right, Left, Up.

    TextChanged event is firing with Action = Remove.

    How to filter such events?

  • Posted 23 September 2018, 8:04 pm EST

    Hello Sergey,

    I can observe that this event fires when navigation buttons are pressed.

    However, each type of key triggers this event with different Action, like Navigation keys return Action=Remove, Delete key returns Action=Reset, character keys return Action=Add. So, as I said earlier, the key to filter TextChanged event is by checking which value is e.Action returning.

    If you could further explain your use-case in some more detail, then I would be in a better position to guide you on how exactly to use this event.

    Regards,

    Ruchir

  • Posted 24 September 2018, 6:43 pm EST

    Use case: show asterisk when document is changed.

    Navigation produce Action=Remove.

    Ctrl+Z also produce Action=Remove.

    How to differentiate them?

  • Posted 25 September 2018, 5:17 pm EST

    Hello,

    In order to proceed further over this issue, we need your sample, so that we could a detailed investigation about this and accordingly share some solution with you. Also, if you could share a video of the event being triggered by navigation keys, it would help us to solve the issue even earlier.

    Thanks,

    Ruchir

  • Posted 25 September 2018, 9:28 pm EST

    Hello,

    Please check this example:

    https://drive.google.com/open?id=1rAqpVBuWMLLGXpUhC-h5Ss5VmhnNVPmw

    Run application.

    Insert a link with Text = “1” and URL = “1”: Window title changed to “Changed”

    Press button Save: Window title changed to “”.

    Click mouse inside document.

    Press Left, Up: : Window title changed to “Changed” but shouldn’t.

  • Posted 26 September 2018, 5:44 pm EST

    Thank you for sharing the sample.

    I am in discussion with the developer about this [Tracking ID: 344946]. I would share the update with you as soon as I get one.

    Regards,

    Ruchir

  • Posted 19 November 2018, 2:56 pm EST

    Hi,

    We are happy to inform you that the issue is now fixed in the latest release build. You can access it by updating ComponentOne using C1Live (installed at C:\Program Files (x86)\ComponentOne\C1Live lcoation) or you can use the following URL to download the assemblies: http://prerelease.componentone.com/dotnet40/c1wpflibrary/2018-t3/C1WPFBasicLibrary.4_4.0.20183.611.zip

    Thanks,

    Ruchir

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels