Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

"find", "replace", and "gotoline" keyb. shortcuts do not override Firefox defaults #442

Closed
hjwp opened this Issue · 12 comments

6 participants

@hjwp

so:

"find" (ctrl+f) pops up the dialog, but also puts the users focus into the firefox search menu. fairly annoying
"go to line" (ctrl+l) puts the focus on the address bar. also annoying.
"replace" (ctrl+r) refreshes the page. totally unusable :-(

looking into it, i see there is code to prevent defaults etc, but it seems not to work on firefox... it's ok on Chrome (surprising, because it's harder in my experience to steal keyboard shortcuts from chrome...)

@gissues:{"order":45.962732919254904,"status":"backlog"}

@mattpardee

Hello,

Could you provide us with some more details: which version of FireFox, and on which OS?

@hjwp

Firefox 6.0.2 on, um, Windows Vista :-(

@aychedee

Just tested on windows XP, with firefox 7.0.1 - all 3 issues also occur.

@gpjt

I'm seeing it on 6.0.2 on Vista. Happens in both our app (I work with hjwp and aychedee) and on the demo at http://ace.ajax.org/build/kitchen-sink.html

@aychedee

confirm the issue is also present on XP/7.0.1 against the official demo...

@hjwp

have tried a few hacks - like an event.stopEvent(e); earlier on, at line 7922 in ace-uncompressed.js - but to no avail as yet...

@hjwp

just spun up an oneiric vm - the issue does not occur on 7.0.1 on Ubuntu

@hjwp

given that FF behaves differently on different platforms, i'd call it a firefox bug... In the meantime, we're looking to replace the default prompt with our own jQuery-UI one... would you guys be interested in seeing the code when we're done?

@gte559z

hjwp, I'd like to take a look at the code when you're done.

@hjwp

Well, the full code is available to anyone that signs up at http://www.pythonanywhere.com - we don't obfuscate.

But here are some highlights:

    function addKeyBindings() {
        var canon = require('pilot/canon');

        canon.addCommand({
            name: 'find',
            bindKey: {
                win: "Ctrl-F",
                mac: "Command-F",
                sender: "editor"
            },
            exec: Anywhere.Editor.showFindDialog
        });

        canon.addCommand({
            name: 'replace',
            bindKey: {
                win: "Ctrl-R",
                mac: "Command-R",
                sender: "editor"
            },
            exec: Anywhere.Editor.showReplaceDialog
        });

        canon.addCommand({
            name: 'replaceAll',
            bindKey: {
                win: "Ctrl-Shift-R",
                mac: "Command-Shift-R",
                sender: "editor"
            },
            exec: Anywhere.Editor.showReplaceDialog
        });

        canon.addCommand({
            name: 'gotoline',
            bindKey: {
                win: "Ctrl-L",
                mac: "Command-L",
                sender: "editor"
            },
            exec: Anywhere.Editor.showGotoLineDialog
        });
    }

and a whole bunch of jquery-ui dialogs trickery, and then:

    function doFind() {
        $('#id_find_dialog').dialog('close');
        var needle = $('#id_find_dialog_find_input').val();
        Anywhere.Editor.editor.find(needle);
    }

    function doReplace() {
        var needle = $('#id_replace_dialog_find_input').val();
        var replacement = $('#id_replace_dialog_replace_input').val();
        Anywhere.Editor.editor.replace(
                replacement,
                { needle: needle, scope: SEARCH_SELECTION }
        );
        Anywhere.Editor.editor.find(needle, { scope: SEARCH_ALL});
    }

    function doGoToLine() {
        $('#id_go_to_line_dialog').dialog('close');
        var line = $('#id_go_to_line_dialog_input').val();
        Anywhere.Editor.editor.gotoLine(line);
    }

    function doReplaceAll() {
        var needle = $('#id_replace_dialog_find_input').val();
        var replacement = $('#id_replace_dialog_replace_input').val();
        Anywhere.Editor.editor.replaceAll(
                replacement,
                { needle: needle, scope: SEARCH_ALL }
        );

hope that helps! And hope to see you signing up too ;-)

@nightwing
Owner

this is caused by firefox prompts becoming page local instead of app local

normally cancelling keydown event cancels keypress as well, but if prompt or alert are called in handler keypress fires on browser window

making useragent.isGecko here fixes this problem

@nightwing
Owner

prompts were removed from find and replace

@nightwing nightwing closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.