How to highlight text in a field without modifying it?

Hi,
I've som big text fileds, I wan the user to be able to search a word in it, and that all the occurences of it get highlighted. BUT I don't want the record to be modified (as I need a script trigger on object save if there's an actual modification.

I don't need/want the highligts to be saved either. I just want the highlight to be show to the user just this one time

Is there a way ?
I thought about superimposing a unstorec calc copye of the field, but that wouldn't work as the user is supposed to modify the text that gets highlighted, so it has to enter th field and go the highlighted text.

You can highlight the found text passages. When the user clicks into the text field, save the text of the field into a variable and compare the text again with the variable when leaving the field.
If text and variable are equal revert the record or remove the highlight textstyle.

2 Likes

Wow, this is quite an interesting question !

You may implement this using a JavaScript editor. This way, the found word(s) would be highlighted without being selected. To implement that you would to display the field in a WebViewer with editing controls limited to search functionality.

1 Like

Pull the text into a global. On exit/save, test for text modifications. If modified, set it back to the actual field.

2 Likes

I took a shot at it, with exaggerated overlaid field movement, that is triggered when the search field is empty or not.

highlight and edit [rivet].zip (89.4 KB)

2 Likes

@rivet Great solution!

Thanks josh, I wrongly discarded it before you mentioned it because I wanted this to also work in list view, so on several records at the same time, but the fact that you mentioned it made me rethink it and find a way to make it work in list view also (using repeated global fields).

Thanks a lot Rivet, your solution is very elegant and was pivotal in my success on this issue, as it both boot me to finally use and understand the while function and allowed me to live test the calucaltion.

I think that solution will be very useful to help in writing debugging calculations and CF. So it's much bigger than the scope of that thread. Maybe you may re-package it a bit to make it a more focused workbench.

I modified your calculation to make it case insensitive, use HighlightText Yellow, put occurrences index in a $variable, as well as an occurrence count. Plus an abridged version of the output containing just the sentences containing a match.

I've uploaded your modified file below (the only modification is the calc)

highlight and edit [rivet_and_vincent].fmp12.zip (91.7 KB)

1 Like

Looks great!, I am glad I could help.

I didn't know that some of the BaseElement functions are more performant than FileMaker native versions. -- thanks for that.

When it comes to calculating stylized text, this setup, is really the only way to do it. It could get a bit fancier by adding an error field (EvaluationError) but that's another thread.

Cheers!

1 Like