Nikhil
Nikhil

Reputation: 182

"Escape" key event propagation

I have hosted Monaco editor in a panel which can be close using "Escape" key. Now if Find widget is open in the editor pressing "Escape" should only close the widget but currently it closes panel as well. Any idea how we can handle this so that only Find widget closes not the panel?

Upvotes: 1

Views: 997

Answers (1)

Nikhil
Nikhil

Reputation: 182

This got answered here https://github.com/Microsoft/monaco-editor/issues/1017. Basically monaco editor give flexibility to add commands

editor.addCommand(monaco.KeyCode.Escape, function() {
    alert('I should close my panel!');

}, '!findWidgetVisible && !inReferenceSearchEditor && !editorHasSelection') 

Upvotes: 3

Related Questions