简体   繁体   中英

how to Rename a tab using Javascript Key events?

选定的选项卡

编辑字段

As you can see in the picture that if i click the selected tab "Navigation" then only the rename option is appearing (pic 2). I want to make this via key board.

JavaScript code:

_makeEditable: function() {
            var instance = this;

            if (instance._isModifiable) {
                var currentItem = instance._navBlock.find('li.selected');
                var currentLink = currentItem.find('a');
                var currentSpan = currentLink.find('span');

                currentLink.click(
                    function(event) {
                        if (event.shiftKey) {
                            return false;
                        }
                    }
                );

You might want to try something like this:

prototype.js:

document.observe('keydown', mainWindowKeyDown);

jquery (not sure about this, I don't use jquery often):

$(function()
{
    $(document).keydown(mainWindowKeyDown);
});

The keydown handler could be something like:

/*  
Called when hitting any key.
*/
function mainWindowKeyDown(e)
{
    if (e.keyCode == 113) // when F2 is pressed
        triggerTabRename();        
    //else if (e.ctrlKey && e.keyCode == 90) // when ctrl + 'z' pressed
    //    doSomethingWhenCtrlZWasPressed(e);
    //else if (e.ctrlKey && e.keyCode == 88) // when ctrl + 'x' pressed
    //    doSomethingWhenCtrlXWasPressed(e);
}

Here you can find a list of keycodes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM