how I can make tern appare in codemirror by extraKeys?


#1

I want to use tooltip with codemirror , so I write function to show it and the function work fine ,when I press the button then the function run , my problem is when I call the function using extraKeys (ctrl_R) then the function not run ,this is my try online : my try
this is the code :

var cm = CodeMirror(document.getElementById("editor"), {
    value: "function myScript() {\n    return 100;\n}",
    mode: "javascript",
    indentUnit: 4,
    lineNumbers: true,
    extraKeys: {
    "Ctrl-R":function()
    		   {
    textMarker = cm.markText({
        line: 1,
        ch: 4
    }, {
        line: 1,
        ch: 10
    }, {
        className: 'marked-text'
    });
    
    $('.marked-text').tooltip({
        title: 'This is a return statement',
        container: 'body',
        delay: { "show": 500, "hide": 100 },
        animation: false
    });
}     	
    		        	
    		        
    		        
    }
});

var textMarker;

$('#add').click(function() {
    textMarker = cm.markText({
        line: 1,
        ch: 4
    }, {
        line: 1,
        ch: 10
    }, {
        className: 'marked-text'
    });
    
    $('.marked-text').tooltip({
        title: 'This is a return statement',
        container: 'body',
        delay: { "show": 500, "hide": 100 },
        animation: false
    });
});

$('#remove').click(function() {
    if (textMarker) {
        textMarker.clear();
    }
}); 

any body can help , what my wrong ?


#2

The way you use extraKeys looks fine, except that you’re binding Ctrl-R while your message talks about Ctrl-Q.


#3

I edit my question and replace ctrl_Q by ctrl_R but the function still not run , so any help ? @marijn you can see jsbin the function not run when I press ctrl_R