Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to refocus / close and reopen prompt #20

Closed
re5et opened this issue May 13, 2010 · 4 comments
Closed

How to refocus / close and reopen prompt #20

re5et opened this issue May 13, 2010 · 4 comments

Comments

@re5et
Copy link

re5et commented May 13, 2010

If i have a keysnail prompt open and it loses focus, I have no idea how to get back to it, or close and reopen it. Is there a simple solution for this that I am missing?

An example of what I mean: I hit M-x then decide to ctrl-tab to a different tab, the prompt will be up but the page in the new tab will have focus, then I have no way back to the prompt. C-g doesn't kill it, and M-x again yeilds: "Prompt is already in use by another command."

@mooz
Copy link
Owner

mooz commented May 14, 2010

Try this code to refocus prompt.

key.setGlobalKey(['C-c', 'p'], function (ev, arg) {
    var p = document.getElementById("keysnail-prompt");
    if (p.hidden)
        return;
    document.getElementById("keysnail-prompt-textbox").focus();
}, 'Focus to the prompt');

And if you want C-g to force close the opened prompt, paste the code below to the bottom of your .keysnail.js file.

hook.setHook('KeyBoardQuit', function (ev) {
    util.rangeInterrupted = true;
    if (key.currentKeySequence.length)
        return;
    command.closeFindBar();

    var marked = command.marked(ev);

    if (util.isCaretEnabled())
    {
        if (marked)
            command.resetMark(ev);
        else
        {
            if ("blur" in ev.target)
                ev.target.blur();
            gBrowser.focus();
            _content.focus();
        }
    }
    else
    {
        goDoCommand("cmd_selectNone");
    }

    if (KeySnail.windowType === "navigator:browser" && !marked)
    {
        key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
        prompt.finish(true);
    }
});

prompt.finish(true) close the opened prompt.

@re5et
Copy link
Author

re5et commented May 14, 2010

perfect. any reason something like this isn't built in? seems really weird that there is no way to toggle it without the mouse (considering the extensions purpose)

@mooz
Copy link
Owner

mooz commented May 14, 2010

No reason. Just I hadn't thought of it :)
OK, I'll add this command to the built-in functions in the next version.

@re5et
Copy link
Author

re5et commented May 14, 2010

super cool, thanks.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants