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

  • From: "Susan Jolly" <easjolly@xxxxxxxxxxxxx>
  • To: <brailleblaster@xxxxxxxxxxxxx>
  • Date: Fri, 10 Jun 2011 09:31:14 -0600

I'm not sure this is the right question to be asking at this point. Based on the discussion a few days ago, it seemed that you wanted to somehow associate the text that a StyledText widget edits to what Chris called the other day your "backing store."


With its default use, StyledText makes a copy of your input and manages it with its default Content model. Any changes are made to this copy. You can, of course, obtain this possibly changed copy via getText() and do anything you want with it.(The SWT TextEditor example shows how to save it to a file.) However, the copy, changed or not, is obviously not connected to any "backing store." Styled Text also allows you to define your own Content model by using its setContent().

You can add various Listeners including ModifyListener so the StyledText widget will inform you when it makes changes. StyledText doesn't support undo, although you could add it. Of course, if you do allow undo then you might want to add logic to see whether there are any net changes although this would probably be too hard. In my experience, most text editors think you've changed a document if you've done any editing even if in fact you've effectively undone all the changes.

I've found two articles that are of some help in using the StyledText widget but it's definitely not easy to understand.
http://www.eclipse.org/articles/StyledText%201/article1.html
http://www.eclipse.org/articles/StyledText%202/article2.html

HTH,
Susan





Other related posts: