Forcing inserted text to be a new item

General TRichView support forum. Please post your questions here
Post Reply
JonRobertson
Posts: 164
Joined: Tue Nov 08, 2011 5:11 pm

Forcing inserted text to be a new item

Post by JonRobertson »

We allow the user to create a "template" that contains "fields", for lack of a better term. The fields are replaced each time a document is opened with the current value. Consider the fields PatientName and PatientAge and this simple template:

PatientName, age PatientAge, was seen today at 11:00.

Now consider a document created for me from this template. If you open the document the day before my birthday, it would read:

Jon Robertson, age 41, was seen today at 11:00.

And if you open the document on or after my birthday:

Jon Robertson, age 42, was seen today at 11:00.

The documents are modifiable by the user. Each "field" item has the Tag set to identify it has a field that is updated each time the document is opened.

I need a way to force inserted text to be a new item. Suppose the user clicks before "age " and removes that text, then clicks between the 42 and the comma and types " years old", resulting in:

Jon Robertson, 42 years old, was seen today at 11:00.

"42" was already a separate item because we created it as such when inserting it into the template. The text typed by the user (" years old") is appended to the "42" item. The next time the document is opened, the line now reads:

Jon Robertson, 42, was seen today at 11:00.

At least that example still makes sense. But there are many others that do not.

I also need to ensure the text inserted is truly a new item, rather than adding to an item that is not a "field". Consider a different example, where First and Last are fields for first name and last name. When the user created the template, they left out the space:

FirstLast was seen today at 11:00.

Our generated version:

JonRobertson was seen today at 11:00.

The user clicks between the 'n' and 'R' and inserts a space. That new space needs to be a unique item. Anything else typed can belong to the same item. IOW, we don't want or need every single character to be a separate item. Essentially, when a user clicks in the RichViewEdit, I want to insert a new (empty) item at that point which will contain any text the user types at that point.

I looked at the TRVWordEnumerator class but did not see anything that looked useful for this request.

Any suggestions would be most appreciated. Thanks!
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You can use text protection for fields: http://www.trichview.com/help/idh_tcust ... ction.html
Include rvprDoNotAutoSwitch and rvprModifyProtect.
Post Reply