Harsha pps
Harsha pps

Reputation: 2208

Is there any 'Click' or 'Enter' event on the ace editor autocomplete popup list?

I want to get the element that has been clicked from the autocomplete popup.

Upvotes: 2

Views: 2167

Answers (2)

Harsha pps
Harsha pps

Reputation: 2208

Found the popup selected item, from the insertMatch, by adding the insertMatch into the completor:

  callback(null,
      wordList.map(function (word) {
          return {
              caption: word,
              value: word,
              completer: {
                  insertMatch: function (editor, data) {
                      console.log("Item clicked: ", data.value);
                      editor.completer.insertMatch({value: data.name});
                  }
              }
       }

Upvotes: 5

Sam Taylor
Sam Taylor

Reputation: 345

Using @Harsha pps 's answer - I also had to add the following to get the word selected word to the editor (and remove the characters typed so far):

editor.removeWordLeft();
editor.insert(data.value);

insertMatch might be a better solution, as suggested by @a user, but I was unable to get this working

Upvotes: 0

Related Questions