mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
27 lines
738 B
JavaScript
27 lines
738 B
JavaScript
const native = require('./build/Release/print_handler.node');
|
|
|
|
/**
|
|
* Arm the print-dialog watcher. Call this BEFORE triggering
|
|
* webContents.print() — the watcher uses an NSTimer in
|
|
* NSRunLoopCommonModes so it fires during the modal run loop
|
|
* that runModalWithPrintInfo: enters.
|
|
*
|
|
* @param {'cancel'|'print'} [action='cancel']
|
|
* @param {number} [timeoutMs=5000]
|
|
*/
|
|
function startWatching (action = 'cancel', timeoutMs = 5000) {
|
|
native.startWatching(action, timeoutMs);
|
|
}
|
|
|
|
/**
|
|
* Stop the watcher and return whether a dialog was dismissed.
|
|
* Call after the print callback has fired.
|
|
*
|
|
* @returns {boolean}
|
|
*/
|
|
function stopWatching () {
|
|
return native.stopWatching();
|
|
}
|
|
|
|
module.exports = { startWatching, stopWatching };
|