I'm now catching mouse click events on textarea elements.
Since I have to stop propagation after processing the event, the caret will not be set as usual when we use click on the textareas with middle key. But I need to set it before doing further works, so I tried to dispatch a mouse event manually.
My code is:
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 1, origEvt.screenX, origEvt.screenY,
origEvt.clientX, origEvt.clientY, false, false, false, false, 0, null);
origEvt.target.dispatchEvent(evt);
...
This code tries to simulate a left click on the same element at the same position. The dispatched event can be caught, but however, the caret is not set.
Could anyone guide me how to do this?