GithubHelp home page GithubHelp logo

el3um4s / ipc-for-electron-window-controls Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 994 KB

Allow the renderer to close, minimize and maximize the window (for desktop Electron)

License: MIT License

TypeScript 100.00%
electron electronjs inter-process-communication ipc maximize minimize node nodejs npm restore

ipc-for-electron-window-controls's Introduction

IPC for Electron: Window Controls

Allow the renderer to close, minimize and maximize the window (for desktop Electron)

NPM link: @el3um4s/ipc-for-electron-window-controls

Use @el3um4s/ipc-for-electron and @el3um4s/renderer-for-electron-window-controls to allow communication between Electron and a web page

Install and use the package

To use the package in a project:

npm i @el3um4s/ipc-for-electron @el3um4s/ipc-for-electron-window-controls @el3um4s/renderer-for-electron-window-controls

Then the preload.ts file:

import { generateContextBridge } from "@el3um4s/ipc-for-electron";
import windowControls from "@el3um4s/ipc-for-electron-window-controls";

const listAPI = [windowControls];

generateContextBridge(windowControls);

In the renderer file:

import windowControls from "@el3um4s/renderer-for-electron-window-controls";

windowControls.minimize();
windowControls.maximize();
windowControls.unmaximize();
windowControls.close();

In the renderer you can use:

globalThis.ipc.windowControls.send("minimize", null);
globalThis.ipc.windowControls.send("maximize", null);
globalThis.ipc.windowControls.send("unmaximize", null);
globalThis.ipc.windowControls.send("close", null);

API: Electron Side

  • minimize - Minimize the window
  • maximize - Maximize the window
  • unmaximize - Unmaximize the window
  • close - Close the window

API: Renderer Side - Request

minimize = (options: { apiKey?: string }): void

example:

import windowControls from "@el3um4s/renderer-for-electron-window-controls";

windowControls.minimize();

maximize = (options: { apiKey?: string }): void

example:

import windowControls from "@el3um4s/renderer-for-electron-window-controls";

windowControls.maximize({ apiKey: "my-api-key" });

unmaximize = (options: { apiKey?: string }): void

example:

import windowControls from "@el3um4s/renderer-for-electron-window-controls";

windowControls.unmaximize();

close = (options: { apiKey?: string }): void

example:

import windowControls from "@el3um4s/renderer-for-electron-window-controls";

windowControls.close();

Types

DefaultApiKey

type DefaultApiKey = "ipc";

ipc-for-electron-window-controls's People

Contributors

el3um4s avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.