Skip to content

Events

jigish edited this page Feb 23, 2013 · 4 revisions

Events are used to execute functions when certain events happen. This page describes them in detail. Events are available in Slate versions 1.0.25 and above.

Usage

slate.on(event, function(event) { // some events will pass another argument in addition to the event name
  // do something
});

Examples

// When a window is opened, if the application is iTerm, move it to the screen's origin
slate.on("windowOpened", function(event, win) {
  if (win.app().name() === "iTerm") {
    win.move({ "x" : "screenOriginX", "y" : "screenOriginY" });
  }
});

// When an app is hidden, log the application's name to the OS X Console.
slate.on("appHidden", function(event, app) {
  slate.log(app.name());
});

List of Events

Window Related

windowOpened

Fires when a window is opened (created).

Callback Parameters: event name, window

windowClosed

Fires when a window is closed.

Callback Parameters: event name, application

windowMoved

Fires when a window is moved.

Callback Parameters: event name, window

windowResized

Fires when a window is resized.

Callback Parameters: event name, window

windowFocused

Fires when a window is focused.

Callback Parameters: event name, window

windowTitleChanged

Fires when a window's title has changed.

Callback Parameters: event name, window

App Related

appOpened

Fires when an app is opened (launched for the first time).

Callback Parameters: event name, app

appClosed

Fires when an app is closed (quit).

Callback Parameters: event name, app

appHidden

Fires when an app is hidden.

Callback Parameters: event name, app

appUnhidden

Fires when an app is unhidden.

Callback Parameters: event name, app

appActivated

Fires when an app is activated (gains focus).

Callback Parameters: event name, app

appDeactivated

Fires when an app is deactivated (loses focus).

Callback Parameters: event name, app

Screen Related

screenConfigurationChanged

Fires when the screen configuration has changed (monitor connected or disconnected).

Callback Parameters: event name only

Something went wrong with that request. Please try again.