Well, this is 7th edition of this excellent book and someone should have already highlighted that when a filter of DocumentFilter class works
1) replace() is called most of the time on user’s interaction with e.g. text field, not just when ‘text is selected and replaced’ but also on regular input and
2) contrary to what can be concluded from previous paragraph (it may mislead), insertString() is called on text inserted to document on construction of the e.g. text field object (as constructor parameter) or ‘injected’ to document by document.insertString()

Have a look at the original text would you think it shows clear understanding of the process? What do you think, am I too sensitive on this? I found this pretty confusing.

Attachments filter.jpg 351.54 KB
7 Years
Discussion Span
Last Post by tomqsm

If you have qualms with the clarity of the writing in the book, or with a particular bug in the code in the book, then why not email the publisher? Of course, the writing might be clear to some people but not to others: your claim that it is unclear is important and perfectly valid, even if someone else thinks that it is clear.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.