Welcome, guest | Sign In | My Account | Store | Cart

A Komodo JavaScript macro that can be used to force the focus back to the Komodo editor after switching between windows (i.e. after using Alt-Tab).

This macro only applies to Windows and Mac OS - where there is an application activated notification event available.

To use this macro - set the macro to trigger on the "On startup" event.

JavaScript, 19 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
if (typeof(window.extensions) == 'undefined') {
    window.extensions = {};
}
if (typeof(window.extensions.resetFocus) == 'undefined') {
    window.extensions.resetFocus = {
        observe: function(subject, topic, data) {
            if (topic == "application-activated") {
                if (ko.views.manager.currentView) {
                    ko.views.manager.currentView.setFocus();
                }
            }
        }
    };

    var observerSvc = Components.classes["@mozilla.org/observer-service;1"].
                    getService(Components.interfaces.nsIObserverService);
    observerSvc.addObserver(window.extensions.resetFocus,
                            "application-activated", false);
}