1.0.5 • Published 7 months ago

nseventmonitor v1.0.5

Weekly downloads
88
License
MIT
Repository
github
Last release
7 months ago

NSEventMonitor

Build Status dependencies Status devDependencies Status

Currently when building menubar apps with Electron, window.on('blur', ...) does not fire if user clicks on other menubar items leaving displayed window on screen.

Native macOS popovers usually hide if user clicks anywhere on screen. This extension attempts to fix that for Electron apps, so the following will never be the case anymore:

Example

import { NSEventMonitor, NSEventMask } from 'nseventmonitor';

let macEventMonitor = new NSEventMonitor();

window.on('blur', () => {
  window.hide();
});

window.on('show', () => {
  // start capturing global mouse events
  macEventMonitor.start((NSEventMask.leftMouseDown | NSEventMask.rightMouseDown), () => {
    window.hide();
  });
});

window.on('hide', () => {
  // stop capturing global mouse events
  macEventMonitor.stop();
});

To run example app:

$ cd example
$ npm i
$ npm start

Electron support

Electron comes with its own Node.js runtime, which may differ from the one installed on your desktop. Therefore all native modules have to be built specifically for Electron.

We strongly advise to use electron-builder and add a postinstall script to your package.json in order to automatically compile native modules for Electron:

electron-builder install-app-deps

Building from source

To compile the extension run the following command:

$ npm i --build-from-source

You can confirm everything built correctly by running the test suite.

To run tests:

$ npm test

Note: tests are currently disabled due to issues with automation on macOS.

1.0.5

7 months ago

1.0.4

10 months ago

1.0.3

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago