![]() rotation: specifies if the screen orientation is different to 0 (normal). ![]() scaleFactor: returns the scale factor of the screen (Float) in case it has (1 will be the default value for any screen without zoom enabled).touchSupport: specifies in a string if the screen uses touch technologies.workAreaSize: provides the dimensions (height and width) of the screen without the taskbar height.The retrieven object (with the mainScreen method) provides more information about the dimension and other properties of the screen: In order to retrieve the height and width of the screen, you can rely on the size property of the returned screen object: var mainScreen = screenElectron.getPrimaryDisplay() Ĭonsole.log(dimensions.width + "x" + dimensions.height) You can read more about the screen module in the documentation of Electron here. I want my new BrowserWindow instance to fill the screen, but I don't want it to be fullscreen in the sense that it creates a new 'virtual screen' or whatever those are called on OS X where the menu bar and window buttons are hidden and t. The getPrimaryDisplay method (or every object in the array returned by the getAllDisplays method) will have a structure similar to: Var allScreens = screenElectron.getAllDisplays() The screen object will grant you access to information about the screen (or the screens in case you have more than one): var mainScreen = screenElectron.getPrimaryDisplay() Instead of accessing the screen global variable in the browser, we need the screen variable available in the Electron constant which you can retrieve using: const electron = require('electron') Both in the renderer and DevTools, window.screen is a reserved DOM property, so replacing it (writing let = require('electron')) will not work. The only and simple reason why screen is not available with the default properties that we see and handle in a normal browser, is that screen is an EventEmitter. In this article, you'll learn why this variable doesn't work as it should and how to retrieve these values properly. So we would use the following snippet to retrieve the dimensions of the screen using Javascript in the Browser: var monitorWidth = screen.width Ĭonsole.log(monitorWidth + "x" + monitorHeight) There is no public standard that applies to the screen object, however all major browsers support it. Tipically, the screen object contains information about the user screen in the Browser.
0 Comments
Leave a Reply. |