# Customize freetext tool to change text and behavior programatically

**URL:** <https://pdfjs.community/t/customize-freetext-tool-to-change-text-and-behavior-programatically/94>\
**Category:** Technical Support\
**Created:** [June 26, 2020, 7:35am UTC](https://pdfjs.community/t/customize-freetext-tool-to-change-text-and-behavior-programatically/94 "2020-06-26T07:35:21Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![rabiraj](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rabiraj](https://pdfjs.community/u/rabiraj)\
**Post date:** [June 26, 2020, 7:35am UTC](https://pdfjs.community/t/customize-freetext-tool-to-change-text-and-behavior-programatically/94/1 "2020-06-26T07:35:21Z")

</div>

How can I customize freetext tool for following:

A) change initial text (possibly from custom drop-down selection)  
B) It automatically goes to edit more, how can I programatically come out of edit more since I will be changing the text programatically  
C) Upon coming out of edit mode, it shows context menu. I do not want to show context menu after the text is edited. Only when user clicks on this annotation, I want to show the context menu, like in all other annotations.

I tried following to change initial text, but it did not work

```
  var Tools = this.wvInstance.Tools;
  var Annotations = this.wvInstance.Annotations
  var freeTextMouseUp = Tools.FreeTextCreateTool.prototype.mouseLeftUp;
  Tools.FreeTextCreateTool.initialText = 'REDACTED'
  Tools.FreeTextCreateTool.prototype.mouseLeftUp = function() {
    if (this.annotation) {
      this.text = 'REDACTED'
      instance.docViewer.getAnnotationManager().redrawAnnotation(this.annotation);
    }
    freeTextMouseUp.apply(this, arguments);
  }
```

---

_[View the full topic](https://pdfjs.community/t/customize-freetext-tool-to-change-text-and-behavior-programatically/94)._
