开发者

how to Rename a tab using Javascript Key events?

开发者 https://www.devze.com 2023-03-09 03:34 出处:网络
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.

how to Rename a tab using Javascript Key events?

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 = curren开发者_如何学CtLink.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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号