[brailleblaster] Re: How can I test whether a StyledText has changed?

  • From: Chris von See <chris@xxxxxxxxxxxxx>
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Fri, 10 Jun 2011 08:30:30 -0700

StyledText has two "modify listener" methods that are called when the content has changed. See the "addModifyListener" and "addExtendedModifyListener()" methods in the Javadoc.


Cheers
Chris



On Jun 10, 2011, at 7:41 AM, Michael Whapples wrote:

I can think of a number of ways of achieving what you ask, but I don't know which is seen to be the best option.

1. Keep a copy of what is written to the file in memory, on closing compare this to what would be written if the document were to be saved. 2. You might be able to listen for events which indicate the document has changed and then set a boolean variable to true to indicate document changed.

There may be others but those are the ones which first come to mind.

The other thing to remember is that the styled text control doesn't know when you last saved its contents (the responsibility for saving clearly should not be anywhere near styled text control) and therefore you will not find anything in StyledText which will tell you the answer.

Michael Whapples
On 10 Jun 2011, at 15:26, John J. Boyer wrote:

Perhaps Susan knows the answer, since she haslooked at the StyledText so much. When the user indicated that a document is to be closed, how can I
tel if the content of either of the views has changed? Then I would
prompt the user with the usual close dialog box.

Thanks,
John

--
John J. Boyer; President, Chief Software Developer
Abilitiessoft, Inc.
http://www.abilitiessoft.com
Madison, Wisconsin USA
Developing software for people with disabilities






Other related posts: