How to get cursor coordinates in CKEditor

370 views Asked by At

I want to know the coordinates of the mouse pointer when I r-click on CKEditor

I added a few items to the context menu of CKEditor. i want when I select a certain item, the other a notice appeared also in place i r_click

 $(document).ready(function () {
    var ck = CKEDITOR.replace('txtNoidungBR', 'vi');
    var $DK = $('#divAddDK');
    /*Thêm điều kiện*/
    ck.on('instanceReady', function (e) {

        ck.addCommand("addDK", {
            exec: function (ck) {
            /*I want to set coordinates to $DK = coordinates of context menu when i r-click*/
                $DK.css({ 'left': 600, 'top': 400 }).toggle(300);

            }
        });

        ck.addMenuGroup('BRDT');

        var addDK = {
            label: 'Thêm điều kiện',
            command: 'addDK',
            group: 'BRDT'
        };

        ck.contextMenu.addListener(function (element, selection) {
            return {
                addDK: CKEDITOR.TRISTATE_OFF
            };
        });

        ck.addMenuItems({
            addDK: {
                label: 'Thêm điều kiện',
                command: 'addDK',
                group: 'BRDT',
                order: 1
            }
        });
    });
});

help me. thaks

1

There are 1 answers

0
Dusty J On

You'll need to track the mouse yourself, as ckeditor doesn't give you the mouse event.

See this answer for details on that: How to get the mouse position without events (without moving the mouse)?