DocuVieware Reference Guide
Reference Guides > JavaScript API > Actions > Interface > AddSelectedTextContextMenuItem

This function allows you to add a custom item to the selected text contextual menu.

AddSelectedTextContextMenuItem: function (docuViewareID, caption, callback)


The identifier for the DocuVieware™ instance you want to add the contextual menu item to.
A string that represent the text that will be displayed as the menu option.
A function that will be executed when the user clicks on the menu item.
It provides an array of objects containing all the selected text areas with the following prototype: { pageNo, coordinates: { top, left, height, width } }.
The measurement unit for the coordinates is inches relative to the document page.

Return Value

1 if error, 0 if success.

Example of usage

This code adds two context menu items, one will display the coordinates of the selected text sections in the console and the other will highlight the selected text in green.

DocuViewareAPI.AddSelectedTextContextMenuItem("DocuVieware1", "Coordinates", function (areas) { console.log(areas); });
DocuViewareAPI.AddSelectedTextContextMenuItem("DocuVieware1", "Green", function () { DocuViewareAPI.HighlightSelectedText("DocuVieware1", "#00FF00"); });