Ticket #4812: 4812.patch

File 4812.patch, 3.1 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/dialog/plugin.js

     
    654654                                parentElement.$.style.zIndex  -= Math.floor( this._.editor.config.baseFloatZIndex / 2 );
    655655                                CKEDITOR.dialog._.currentTop = this;
    656656                        }
    657 
    658                         // Register the Esc hotkeys.
    659                         registerAccessKey( this, this, '\x1b', null, function()
    660                                         {
    661                                                 this.getButton( 'cancel' ) && this.getButton( 'cancel' ).click();
    662                                         } );
    663 
     657                       
    664658                        // Reset the hasFocus state.
    665659                        this._.hasFocus = false;
    666660
     
    18251819                var ctrl = evt.data.$.ctrlKey || evt.data.$.metaKey,
    18261820                        alt = evt.data.$.altKey,
    18271821                        shift = evt.data.$.shiftKey,
    1828                         key = String.fromCharCode( evt.data.$.keyCode ),
     1822                        key = String.fromCharCode( evt.data.getKey() ),
    18291823                        keyProcessor = accessKeyProcessors[( ctrl ? 'CTRL+' : '' ) + ( alt ? 'ALT+' : '') + ( shift ? 'SHIFT+' : '' ) + key];
    18301824
    18311825                if ( !keyProcessor || !keyProcessor.length )
    18321826                        return;
    18331827
    18341828                keyProcessor = keyProcessor[keyProcessor.length - 1];
    1835                 keyProcessor.keyup && keyProcessor.keyup.call( keyProcessor.uiElement, keyProcessor.dialog, keyProcessor.key );
    1836                 evt.data.preventDefault();
     1829                if( keyProcessor.keyup )
     1830                {
     1831                        keyProcessor.keyup.call( keyProcessor.uiElement, keyProcessor.dialog, keyProcessor.key );
     1832                        evt.data.preventDefault();
     1833                }
    18371834        };
    18381835
    18391836        var registerAccessKey = function( uiElement, dialog, key, downFunc, upFunc )
  • _source/plugins/dialogui/plugin.js

     
    207207                                if ( elementDefinition.size )
    208208                                        attributes.size = elementDefinition.size;
    209209
    210                                 // If user presses Enter in a text box, it implies clicking OK for the dialog.
    211                                 var me = this, keyPressedOnMe = false;
     210                                // If user presses Enter/Esc in a text box, it implies clicking OK/Cancel button for the dialog.
     211                                var me = this, keyPressedOnMe = false, keyMap = { 13: 'ok', 27: 'cancel' };
    212212                                dialog.on( 'load', function()
    213213                                        {
    214214                                                me.getInputElement().on( 'keydown', function( evt )
    215215                                                        {
    216                                                                 if ( evt.data.getKeystroke() == 13 )
     216                                                                if ( evt.data.getKeystroke() in keyMap )
    217217                                                                        keyPressedOnMe = true;
    218218                                                        } );
    219219
    220220                                                // Lower the priority this 'keyup' since 'ok' will close the dialog.(#3749)
    221                                                 me.getInputElement().on( 'keyup', function( evt )
     221                                                me.getInputElement().on( 'keypress', function( evt )
    222222                                                        {
    223                                                                 if ( evt.data.getKeystroke() == 13 && keyPressedOnMe )
     223                                                                var keyCode = evt.data.getKeystroke();
     224                                                                if ( keyCode in keyMap && keyPressedOnMe )
    224225                                                                {
    225                                                                         dialog.getButton( 'ok' ) && setTimeout( function ()
    226                                                                         {
    227                                                                                 dialog.getButton( 'ok' ).click();
    228                                                                         }, 0 );
     226                                                                        var button = dialog.getButton( keyMap[ keyCode ] );
     227                                                                        button && button.click();
    229228                                                                        keyPressedOnMe = false;
    230229                                                                }
    231230                                                        }, null, null, 1000 );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy