Skip to content
This repository was archived by the owner on Apr 1, 2020. It is now read-only.
13 changes: 12 additions & 1 deletion main/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as minimist from "minimist"
import * as path from "path"

import { app, BrowserWindow, ipcMain, Menu } from "electron"
import { app, BrowserWindow, ipcMain, Menu, systemPreferences } from "electron"

import * as PersistentSettings from "electron-settings"

Expand Down Expand Up @@ -182,6 +182,17 @@ export function createWindow(
width: windowState.bounds.width,
})

if (process.platform.includes("darwin")) {
const pressAndHold: boolean = systemPreferences.getUserDefault(
"ApplePressAndHoldEnabled",
"boolean",
)

if (!pressAndHold) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be pressAndHold (no !), since if ApplePressAndHoldEnabled is enabled, we want to disable it.

systemPreferences.setUserDefault("ApplePressAndHoldEnabled", "boolean", "true")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, super cool! Didn't know we could do this. This will alleviate a common pain point on OSX. Nice find @akin909 馃挴

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be false not "true", since it needs to be a bool and it should be setting this value to false.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that bit is quite confusing as the type for it from electron and the docs state the argument is a string got stuck on that for a while, seems like an issue for electron and their types for this function

}
}

if (windowState.isMaximized) {
currentWindow.maximize()
}
Expand Down