Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » How do I detect if the data in a RichEdit was changed by user?
How do I detect if the data in a RichEdit was changed by user? [message #53028] Wed, 12 February 2020 10:47 Go to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
I have a RichEdit in a tab, and when the user clicks away I want to save the data if it was changed, but
I cannot determine how to find out if the data was changed.

IsModified() does not seem to work as advertised Smile and I cannot find any other clue.

An obvious way would be to check if it contains undo-dat, but for some reason undo-buffer is
not accessible (why-ever not?) and using PickUndoData() CLEARS the editor (why?)

[Updated on: Wed, 12 February 2020 11:56]

Report message to a moderator

Re: How do I detect if the data in a RichEdit was changed by user? [message #53035 is a reply to message #53028] Fri, 14 February 2020 09:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Admittedly, the issue is that IsModified queries the whole widget tree, which I now find quite confusing. Anyway, current solution is IsModifySet.

That said, I agree that current situation is confusing, so I am changing
ResetModify -> ClearModify
ClearModify -> ClearModifyDeep
IsModifySet -> IsModified

(While this is quite a change of contract, search through all of my projects revealed that a) Modify flag is really not used that much often b) current use actually rather expects above behaviour).

All that said, this whole solution is not able to check for the situation where you change data and change it back. So maybe even better would be to actually compare original content witch current one, or its hash...
Re: How do I detect if the data in a RichEdit was changed by user? [message #53055 is a reply to message #53035] Tue, 18 February 2020 13:49 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
thx mirek

As a cop-out at the moment I do a CRC32 on the data before and after to check if it was changed

I will change my code to use IsModifySet and see how that works out ..

but still think that checking the undo-buffer would give a surer indication ...


Re: How do I detect if the data in a RichEdit was changed by user? [message #53058 is a reply to message #53055] Tue, 18 February 2020 18:17 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I think crc32 is too small for this. I would rather use MD5 or even SHA1 (which are both simple to do in U++).

Mirek
Previous Topic: Does a Ctrl may be a RichObject ?
Next Topic: how to solve WhenEnter event to RichEdit
Goto Forum:
  


Current Time: Thu Mar 28 16:42:35 CET 2024

Total time taken to generate the page: 0.01123 seconds