how to clear highlighted text of search result?

64 views
Skip to first unread message

s.crandall

unread,
Apr 27, 2016, 1:59:07 PM4/27/16
to PDFTron WebViewer
I would like to define an event where the highlighted text is cleared if the user clicks outside of the search input field.  I am using the current downloaded trial version of WebViewer Client (4/20/16).  Is the method "setToolMode(tool)" the correct one to use?  Could you please provide sample code so that I can learn how to implement this method?  Thank you for your help!  -Suzanne

Kristian Hein

unread,
Apr 27, 2016, 4:12:40 PM4/27/16
to PDFTron WebViewer
Hello,

By highlighted text, do you mean a highlighted search result or do you mean the text in the search input field?

If it is the prior, then the highlighted text is cleared by clicking with most tools, for example, the text selection tool. Pan and signature tools will keep the selection.

s.crandall

unread,
Apr 28, 2016, 12:20:29 PM4/28/16
to PDFTron WebViewer
Yes, I mean the highlighting on the text that results from a search.  Thank you for your suggestion, however the custom UI toolbar I am working with does not make use of other "tools" that will "clear" the highlighting when clicked.  I've included a screen shot below.  I need to code an event that clears (or "resets") the highlighting when the user clicks anywhere in the viewport outside of the input field.  Could you please help me with some sample code?  Thank you for your help!  -Suzanne


Kristian Hein

unread,
Apr 28, 2016, 2:57:00 PM4/28/16
to PDFTron WebViewer

You can clear the highlighted text when clicking outside of the search box by adding this code to ReaderControl.js

$('#searchBox').on('blur', function() {
    readerControl.docViewer.clearSelection();
});
Reply all
Reply to author
Forward
Message has been deleted
0 new messages