Skip to content

Commit

Permalink
fix(color-picker): dismiss color picker by clicking outside color pic…
Browse files Browse the repository at this point in the history
…ker (#793)

* fix(color-picker): dismiss color picker by clicking outside color picker

fixes #461

* fix: remove console.log
2xAA authored Nov 29, 2022
1 parent c13f54a commit 015b84a
Showing 4 changed files with 32 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/application/worker/store/modules/modules.js
Original file line number Diff line number Diff line change
@@ -91,7 +91,6 @@ async function initialiseModuleProperties(
prop.type in store.state.dataTypes &&
store.state.dataTypes[prop.type].inputs
) {
console.log(propKey);
const dataTypeInputs = store.state.dataTypes[prop.type].inputs();
const dataTypeInputsKeys = Object.keys(dataTypeInputs);

5 changes: 3 additions & 2 deletions src/background/background.js
Original file line number Diff line number Diff line change
@@ -48,8 +48,9 @@ app.on("ready", async () => {
"true"
);

createWindow("mainWindow");
createWindow("splashScreen");
createWindow({ windowName: "mainWindow" });
createWindow({ windowName: "splashScreen" });
createWindow({ windowName: "colorPicker", options: { show: false } });
});

// Exit cleanly on request from parent process in development mode.
21 changes: 18 additions & 3 deletions src/background/window-prefs.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import store from "../media-manager/store";
import { autoUpdater } from "electron-updater";
import { checkMediaPermission } from "./check-media-permission";
import { setProjectNames, setCurrentProject } from "./projects";
import { createWindow, windows } from "./windows";
import { closeWindow, createWindow, windows } from "./windows";
import { updateMenu } from "./menu-bar";
import { getMediaManager } from "./media-manager";

@@ -29,7 +29,18 @@ const windowPrefs = {
skipTaskbar: true,
fullscreenable: false
},
unique: true
unique: true,
create(window) {
window.on("close", e => {
e.preventDefault();

window.hide();
});

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

mainWindow: {
@@ -95,7 +106,11 @@ const windowPrefs = {
};

ipcMain.on("open-window", (event, message) => {
createWindow(message, event);
createWindow({ windowName: message }, event);
});

ipcMain.on("close-window", (event, message) => {
closeWindow({ windowName: message });
});

ipcMain.on("modv-ready", () => {
14 changes: 11 additions & 3 deletions src/background/windows.js
Original file line number Diff line number Diff line change
@@ -6,11 +6,12 @@ import { windowPrefs } from "./window-prefs";

const windows = {};

function createWindow(windowName, event) {
function createWindow({ windowName, options = {} }, event) {
updateMenu();

if (windowPrefs[windowName].unique && windows[windowName]) {
windows[windowName].focus();
windows[windowName].show();

if (event) {
event.reply("window-ready", {
@@ -31,7 +32,8 @@ function createWindow(windowName, event) {

// Create the browser window.
windows[windowName] = new BrowserWindow({
...windowOptions
...windowOptions,
...options
});

if (typeof windowPrefs[windowName].create === "function") {
@@ -72,4 +74,10 @@ function createWindow(windowName, event) {
}
}

export { windows, createWindow };
function closeWindow({ windowName }) {
if (windows[windowName]) {
windows[windowName].close();
}
}

export { windows, createWindow, closeWindow };

0 comments on commit 015b84a

Please sign in to comment.