LMSouq
moodle-core Open

fire keyPressEvent in tinyMce

MA
MartinM
1 month ago
3 views
Problem Description
I'm customizing tinyMCE in Moodle (e-learning). I've added a toolbar button which sets focus into a text area and adds two dollar signs in it. What I need is to place cursor between those signs, so that user can start typing between them. Probably the best approach is just to press left arrow programaticlly, isn't it? But I can't figure out how to do that. Here is the code: tinyMCE.init({ mode : "textareas", theme : "advanced", theme_advanced_buttons1 : "mybutton,bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,link,unlink", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", plugins : 'inlinepopups', setup : function(ed) { // Add a custom button ed.addButton('mybutton', { title : 'My button', image : 'img/example.gif', onclick : function() { ed.focus(); ed.selection.setContent('$$'); } }); } }); Thanks

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base