window
Control operations for plugin window display, hide, fullscreen, etc.
Below are common examples of window
functionalities:
Methods
show()
Show and focus the window.
Returns
Promise<>
showInactive()
Show the window but don't focus on it.
Returns
Promise<>
hide()
Hide the plugin window.
Returns
Promise<>
focus()
Give the plugin window focus.
Returns
Promise<>
minimize()
Minimize the plugin window.
Returns
Promise<>
isMinimized()
Determine if the window is minimized.
Returns
Promise<minimized: boolean>
minimized
boolean - Whether the window is minimized
restore()
Restore the plugin window from a minimized state to its previous state.
Returns
Promise<>
maximize()
Maximize the plugin window. If the window has not yet been displayed, this method will also show it (but not focus on it).
Returns
Promise<>
unmaximize()
Unmaximize the plugin window.
Returns
Promise<>
isMaximized()
Determine if the window is maximized.
Returns
Promise<maximized: boolean>
maximized
boolean - Whether the window is maximized
setFullScreen(flag)
Set whether the window should be in fullscreen mode.
flag
boolean - Whether to set as fullscreenReturns
Promise<>
isFullScreen()
Determine if the window is in fullscreen mode.
Returns
Promise<fullscreen: boolean>
fullscreen
boolean - Whether the window is in fullscreen
setAspectRatio(aspectRatio)
This will make the window maintain its aspect ratio.
aspectRatio
Float - The aspect ratio to maintain (width / height)Returns
Promise<>
setBackgroundColor(backgroundColor)
Set the background color of the window.
backgroundColor
String - This parameter represents the HEX code of your desired background color.Returns
Promise<>
Note 1: This property can be set directly in manifest.json.
Note 2: This setting is mainly used to set the default background color of the window when the HTML/CSS content is not yet complete. Proper setting can avoid the flickering of the window display.
setSize(width, height)
Set window size.
width
Integer - window widthheight
- Integer - window heightReturns
Promise<>
Note: This property can be set directly in manifest.json.
getSize()
Get window size.
Returns
Promise<Integer[]>
setBounds(bounds)
Adjust the window size and move it to the provided bounds. Any properties not provided will default to their current values.
getBounds()
Get window bounds.
Returns
Promise<Rectangle[]>
- object representing the window bounds
setResizable(resizable)
Set whether the window supports resizing.
resizable
boolean - whether resizing is supportedReturns
Promise<>
Note: This property can be set directly in manifest.json.
isResizable()
Whether the window supports resizing.
Returns
Promise<resizable: boolean>
resizable
boolean
setAlwaysOnTop(flag)
Set whether the window should always be displayed in front of other windows.
flag
booleanReturns
Promise<>
isAlwaysOnTop()
Whether the window should always be displayed in front of other windows.
Returns
Promise<alwaysOnTop: boolean>
alwaysOnTop
boolean
setPosition(x, y)
Move the window to x and y.
x
Integery
IntegerReturns
Promise<>
getPosition()
Get plugin window coordinates x and y.
Returns
Promise<position: Integer[]>
position
Integer[]x - position[0]
y - position[1]
setOpacity(opacity)
Set the opacity of the window, values outside the range are limited to the [0, 1] range.
opacity
number - between 0.0 (completely transparent) and 1.0 (completely opaque)Returns
Promise<>
getOpacity()
Get window opacity, between 0.0 (completely transparent) and 1.0 (completely opaque).
Returns
Promise<opacity: number>
opacity
number
flashFrame(flag)
Start or stop flashing the window to attract the user's attention.
flag
boolean - whether to flashReturns
Promise<>
setIgnoreMouseEvents(ignore)
Ignore all mouse events within the window. All mouse events occurring in this window will be passed to the window below it but if this window has focus, it will still receive keyboard events.
ignore
boolean - whether to ignore mouse eventsReturns
Promise<>
Combined with the setAlwaysOnTop() feature, you can create a special window that floats at the top of the screen and is permeable to mouse clicks.
capturePage(rect)
Capture a snapshot of the page within the specified rect
area. Omitting rect
will capture the entire visible page.
rect
object - Optional, screenshot rangex
numbery
numberwidth
numberheight
number
Returns
Promise<[NativeImage](https://www.electronjs.org/docs/latest/api/native-image)>
setReferer(url)
Sets the current referer URL. Once set, subsequent requests will utilize this referer.
url
string - The URL of the referer.Returns
void
Last updated