I'm working on an etherpad plugin that provides a special autocomplete during text editing. For this I need to know where the user's caret is. However I have no idea if the user moves the caret with a mouse-click, as I couldn't find an appropriate hook for that.
As a first step solving this problem I'd like catch mouse-click events. (If I could catch the click event, I'm still unsure how to find out the caret position, but at least I'd know when to deal with it.) Any help appreciated.
From the ep_tasklist plugin - https://raw.githubusercontent.com/JohnMcLear/ep_tasklist/master/static/js/ace_inner.js with some minor modifications, use this as a point of reference for what you are trying to accomplish.
Just bind a click listener event to the inner doc body
exports.postAceInit = function(hook, context){
context.ace.callWithAce(function(ace){
var doc = ace.ace_getDocument();
$(doc).find('#innerdocbody').on("click", underscore(SOMEFUNCTIONINCORRECTCONTEXT).bind(ace));
}, 'myPlugin', true);
}
I assumed you neeed to keep the context of ace too, if not you don't need to use the underscore bind functionality. IE
exports.postAceInit = function(hook, context){
context.ace.callWithAce(function(ace){
var doc = ace.ace_getDocument();
$(doc).find('#innerdocbody').on("click", function(){
console.log("hello world")
});
}, 'myPlugin', true);
}