1

I am using an open source editor called firepad in a web app. The underlying text editor is Ace. I found another post here explaining how to create a readOnly block of code in Ace editor: Ace Editor: Lock or Readonly Code Segment

This code works for me to make a specified segment readonly, however I want to be able to remove the readOnly restriction. I can delete the ace Marker that denotes the locked are, but I still can't type in the range. I would like to delete the keyboard handler. This is what my code looks like:

    editor.keyBinding.addKeyboardHandler({
        handleKeyboard : function(data, hash, keyString, keyCode, event) {
            if (hash === -1 || (keyCode <= 40 && keyCode >= 37)) return false;

            if (intersects(range)) {
                return {command:"null", passEvent:false};
            }
        }
    });

I can't find any documentation on the addKeyboardHandler method online. Any help would be much appreciated!

Community
  • 1
  • 1
jmsprintz
  • 13
  • 2

1 Answers1

0

use removeKeyboardHandler method to remove it https://github.com/ajaxorg/ace/blob/f757c8568/lib/ace/keyboard/keybinding.js#L80

var kb = { handleKeyboard : function() {...} }
editor.keyBinding.addKeyboardHandler(kb) // add kb
editor.keyBinding.removeKeyboardHandler(kb) // remove kb
a user
  • 23,300
  • 6
  • 58
  • 90