Documentation/window
namespace

window

jsdoc/window.js:1

Functions for working with the current JSplitter panel and accessing it's properties.

property

DlgCode

jsdoc/window.js:7
DlgCode

Indicates which keys should be processed by the panel.
See https://docs.microsoft.com/en-us/windows/desktop/dlgbox/wm-getdlgcode for more info.

Returns

number —

See Flags for flags like DLGC_WANTARROWS

Example

window.DlgCode = DLGC_WANTALLKEYS;
propertyreadonly

DPI

jsdoc/window.js:18
DPI: number

Window DPI. This value never changes while foobar2000 is running. If you change DPI settings, you must restart the application.

property

DrawMode

jsdoc/window.js:74
DrawMode: number = 0

Current graphics rendering mode.
0 (default) - GDI+
1 - Direct2D
IMPORTANT: After switching the rendering mode, all drawing objects created for the other mode will be unavailable for use in the current mode.
Therefore, the developer should create all drawing objects only after changing the mode.
Ideally, the mode change should be made in the VERY first line of the main script to avoid accidentally creating objects of the wrong type.
Also, calling any of d2d.* methods for creating objects like fonts, bitmaps or effects, will cause a script crash until the DrawMode is set to 1 at least once (in this case, the resources required for D2D operation are initialized). D2D rendering may differ from GDI and methods for both backends can not be expected to be 100% pixel equivalent.

property

EraseOnRepaint

jsdoc/window.js:26
EraseOnRepaint: boolean = true

Set whether the JSplitter panel should be cleared with background color before raising on_paint callback.
Default value: true.

Example

"use strict";
window.DrawMode = 0;
window.EraseOnRepaint = false;

let ww = 0;
let wh = 0;

const alphabet = 'アァカサタナハマヤャラワガザダバパイィキシチニヒミリヰギジヂビピウゥクスツヌフムユュルグズブヅプエェケセテネ�メレヱゲゼデベペオォコソトノホモヨョロヲゴゾドボポヴッンABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%&*';
const fontSize = 16;
const font = gdi.Font("Consolas", fontSize, 1);
const drops = [];

function on_size(width, height) {
    ww = width;
    wh = height;
    if(ww > 0 && wh > 0) {
        const columns = Math.floor(ww / fontSize);
        drops.length = columns;
        for (let i = 0; i < columns; i++) if (isNaN(drops[i])) drops[i] = 0;
    }
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, 0x0D000000);

    for (let i = 0; i < drops.length; i++) {
    const text = alphabet.charAt(Math.floor(Math.random() * alphabet.length));
    const x = i * fontSize;
    const y = drops[i] * fontSize;

    gr.GdiDrawText(text, font, 0xFF00FF00, x, y, fontSize, fontSize * 4 / 3);

    if (y > wh && Math.random() > 0.975)
        drops[i] = 0;
    else
        drops[i]++;
    }	
}

window.SetInterval(() => { window.Repaint(); }, 50);
property

HandOnButtons

jsdoc/window.js:700
HandOnButtons: boolean = false

Switches the mouse cursor for all buttons either to the hand or to the arrow. This property also affects all subsequently created buttons. This property can be changed individually for each button (see ButtonObject class).

propertyreadonly

Height

jsdoc/window.js:198
Height: number
propertyreadonly

HostWindowTitle

jsdoc/window.js:204
HostWindowTitle: string

Returns the title of the nearest named container hosting the panel.

propertyreadonly

ID

jsdoc/window.js:87
ID: number

Window handle

propertyreadonly

InstanceType

jsdoc/window.js:95
InstanceType: number

You need this to determine which GetFontXXX and GetColourXXX methods to use, assuming you want to support both interfaces.
See UIInstanceType
0 - if using Columns UI
1 - if using default UI.

propertyreadonly

IsFocused

jsdoc/window.js:117
IsFocused: boolean

Indicates whether this JSplitter panel currently has keyboard focus. This reflects the same focus state reported by on_focus: it is true only while the panel window itself owns keyboard focus.

propertyreadonly

IsToolbar

jsdoc/window.js:106
IsToolbar: boolean

Indicates whether this JSplitter panel is hosted as a toolbar item in Columns UI.
This property is only meaningful when using Columns UI: it is true for a toolbar panel and false for a regular panel.

It is always false in Default User Interface.

propertyreadonly

IsTransparent

jsdoc/window.js:126
IsTransparent: boolean

Only useful within Panel Stack Splitter (Columns UI component)
Depends on setting inside Spider Monkey Panel Configuration window. You generally use it to determine whether or not to draw a background.

propertyreadonly

IsVisible

jsdoc/window.js:136
IsVisible: boolean
propertyreadonly

JsMemoryStats

jsdoc/window.js:189
JsMemoryStats: JsMemoryStats

SpiderMonkey heap and native/external memory statistics. See JsMemoryStats for the returned object properties.

property

MaxHeight

jsdoc/window.js:212
MaxHeight: number

MaxHeight, MaxWidth, MinHeight and MinWidth can be used to lock the panel size.
Do not use if panels are contained within Panel Stack Splitter (Columns UI component) or JSplitter itself

property

MaxWidth

jsdoc/window.js:220
MaxWidth: number
property

MinHeight

jsdoc/window.js:227
MinHeight: number
property

MinWidth

jsdoc/window.js:234
MinWidth: number
propertyreadonly

Name

jsdoc/window.js:241
Name: string

Returns the panel name set in ShowConfigureV2.

propertyreadonly

ScriptInfo

jsdoc/window.js:264
ScriptInfo: ScriptInfo

Information about the panel's main script. The Path property contains its full native filesystem path, or an empty string for an in-memory script. See ScriptInfo for all properties and source types.

propertyreadonly

Tooltip

jsdoc/window.js:272
Tooltip: FbTooltip

Get associated tooltip object.

property

TrackMouseEnterLeaveOnPanels

jsdoc/window.js:709
TrackMouseEnterLeaveOnPanels: boolean = false

Enables tracking of the mouse cursor entering/exiting the panel area. By default = false.
The following functions are used to handle events:
on_panel_mouse_enter(name) - cursor entering the panel area, name is the panel name
on_panel_mouse_leave(name) - cursor leaving the panel area, name is the panel name

property

TrackMouseMoveOnPanels

jsdoc/window.js:719
TrackMouseMoveOnPanels: boolean = false

Enables tracking of the mouse cursor position within the panel area.
By default = false . The following function is used to handle the event:
on_panel_mouse_move(name, x, y, mask): the event of moving the cursor within the panel area, name is the name of the panel, x, y are the coordinates of the point on the panel.

propertyreadonly

Width

jsdoc/window.js:280
Width: number
method

ClearInterval

jsdoc/window.js:300
ClearInterval(timerID)

Parameters

NameTypeDescription
timerIDnumber
method

ClearProperties

jsdoc/window.js:286
ClearProperties(reload_panel)

Clears all current panel properties set by SetProperty, SetProperties or ImportProperties

Parameters

NameTypeDescription
reload_panel = falseoptionalboolean

If true, reloads panel script after clearing

method

ClearTimeout

jsdoc/window.js:293
ClearTimeout(timerID)

Parameters

NameTypeDescription
timerIDnumber
method

CreateButton

jsdoc/window.js:646
CreateButton(x, y, images, hover_images)

Creates a button in the splitter. The button will be created in the root of the window and will be placed at the coordinates (x, y). The function is also passed images to set the appearance of the button. The number of states the button can take will depend on the number of images passed to the function. hover_images - button images displayed when the mouse cursor hovers over the button. The function is flexible enough to create different types of buttons

Parameters

NameTypeDescription
xstring
ystring
images*

// null, string or Array

hover_images = nulloptional*

// null, string or Array

Returns

ButtonObject

Example

var path = fb.FoobarPath + "themes\\lur\\black\\bio.png";
var hpath = fb.FoobarPath + "themes\\lur\\black\\bio_on.png";
// Creates a regular button with the bio.png image, which changes to bio_on.png when the mouse cursor hovers over the button
var a = window.CreateButton(0, 0, path, hpath);
// Creates a checkbox button. The normal state is bio.png, pressed (checkbox checked) - bio_on.png. 
// Note that there are no images for hovering over. 
// Usually, checkboxes do not need them, but you can set them if you want.
var b = window.CreateButton(0, 0, [path, hpath], null);
// You can create a button with three (or more) states. They will switch cyclically when pressed.
// The current state of the button can be obtained using the State property of the button (see ButtonObject class). 
var c = window.CreateButton(0, 0, [path1, path2, path3], [path1_on, path2_on, path3_on]);
method

CreatePopupMenu

jsdoc/window.js:358
CreatePopupMenu()

Returns

MenuObject

Example source

method

CreateThemeManager

jsdoc/window.js:365
CreateThemeManager(class_id)

Parameters

Returns

ThemeManager

Example source

methoddeprecated

CreateTooltip

jsdoc/window.js:373
CreateTooltip(font_name, font_size_px, font_style)
Deprecated.

Note: a single panel can have only a single tooltip object. Creating a new tooltip will replace the previous one.

Deprecated: use Tooltip and SetFont instead.

Parameters

NameTypeDescription
[font_name='Segoeoptionalstring

UI']

font_size_px = 12optionalnumber
font_style = 0optionalnumber

See FontStyle flags

Returns

FbTooltip
methoddeprecated

DefinePanel

jsdoc/window.js:307
DefinePanel(name, options)
Deprecated.

Setups panel and script information and available features.
Can be called only once, so it's better to define it directly in the panel Configure menu.

Deprecated: use DefineScript instead. Panel name can be changed via ShowConfigureV2.

Parameters

NameTypeDescription
namestring

Script name and panel name

options = {}optionalobject
options.author = ''optionalstring

Script author

options.version = ''optionalstring

Script version

options.features = undefinedoptionalobject

Additional script features

options.features.drag_n_drop = falseoptionalboolean

Indicates if drag_n_drop functionality should be enabled

Throws

Error —

If called for a package script, called more than once, or options / options.features is not an object.

method

DefineScript

jsdoc/window.js:327
DefineScript(name, options)

Setup the script information.
Can be called only once for the whole panel.

Parameters

NameTypeDescription
namestring

Script name

options = {}optionalobject
options.author = ''optionalstring

Script author

options.version = ''optionalstring

Script version

options.features = undefinedoptionalobject

Additional script features

options.features.drag_n_drop = falseoptionalboolean

Indicates if drag_n_drop functionality should be enabled

options.features.grab_focus = trueoptionalboolean

Indicates if panel should grab mouse focus

Throws

Error —

If called for a package script, called more than once, or options / options.features is not an object.

method

EditScript

jsdoc/window.js:342
EditScript()

Open the current panel script in the default text editor.
Default text editor can be changed via Edit button on the main tab of ShowConfigureV2.

method

ExportProperties

jsdoc/window.js:348
ExportProperties(fileName)

Exports all current panel properties set by SetProperty to file

Relative filesystem paths are resolved as described in utils.ReadTextFile.

Parameters

NameTypeDescription
fileNamestring

Returns

boolean —

If false, then an error occurred during export

method

GetButton

jsdoc/window.js:673
GetButton(id)

Get a button by its ID

Parameters

NameTypeDescription
idnumber

Returns

ButtonObject
method

GetColourCUI

jsdoc/window.js:388
GetColourCUI(type, client_guid)

Parameters

NameTypeDescription
typenumber

See ColourTypeCUI enum

client_guidoptionalstring

Client GUID

Returns

number —

returns black colour if the requested one is not available.

Throws

Error —

If the panel is not running under Columns UI.

method

GetColourDUI

jsdoc/window.js:396
GetColourDUI(type)

Parameters

NameTypeDescription
typenumber

See ColourTypeDUI enum

Returns

number —

returns black colour if the requested one is not available.

Throws

Error —

If the panel is not running under Default UI.

method

GetFontCUI

jsdoc/window.js:403
GetFontCUI(type, client_guid)

Note: see the example in GetFontDUI.

Parameters

NameTypeDescription
typenumber

See FontTypeCUI enum

client_guidoptionalstring

Client GUID

Returns

?GdiFont —

returns null if the requested font was not found.

Throws

Error —

If the panel is not running under Columns UI.

method

GetFontDUI

jsdoc/window.js:413
GetFontDUI(type)

Parameters

NameTypeDescription
typenumber

See FontTypeDUI enum

Returns

?GdiFont —

returns null if the requested font was not found.

Throws

Error —

If the panel is not running under Default UI.

Example

// To avoid errors when trying to use the font or access its properties, you
// should use code something like this...
let font = window.GetFontDUI(0);
if (!font) {
   console.log("Unable to determine your default font. Using Segoe UI instead.");
   font = gdi.Font("Segoe UI", 12);
}
method

GetPanel

jsdoc/window.js:624
GetPanel(caption)

Get an object for accessing the panel by the caption text. The first panel that matches the argument in text will be returned. The panel text is specified in the caption. By default, it has the value of the panel plugin name, but it can be changed either directly in the window title (Show coords -> Click in caption text) or in the Columns UI placer (Use custom title) or in 'Panel list' (right click on JSplitter window)

Parameters

NameTypeDescription
captionstring

Returns

PanelObject

Throws

Error —

If no child panel exists with the specified name.

method

GetPanelByIndex

jsdoc/window.js:638
GetPanelByIndex(index)

Get an object for accessing the panel by index. the order depends on the position in the window stack: the bottommost window will have index 0.

Parameters

NameTypeDescription
indexnumber

Returns

PanelObject

Throws

Error —

If no child panel exists at index.

method

GetPanelCount

jsdoc/window.js:632
GetPanelCount()

Get child panels count in JSplitter

Returns

number
method

GetProperties

jsdoc/window.js:429
GetProperties()

Get all current panel properties set by SetProperty, SetProperties or ImportProperties

Returns

Map —

Map of panel properties

Example

const props = window.GetProperties();
for(const [key, value] of props) console.log(`Key = ${key}, Value = ${value}`);
method

GetProperty

jsdoc/window.js:439
GetProperty(name, default_val)

Get value of property.
If property does not exist and default_val is not undefined and not null, it will be created with the value of default_val.

Note: leading and trailing whitespace are removed from property name.

Parameters

NameTypeDescription
namestring
default_valoptional*

Returns

*
method

ImportProperties

jsdoc/window.js:452
ImportProperties(fileName, reload_panel)

Imports panel properties from file and (optionally) reloads the panel script
DOES clear all existing panel properties.

Relative filesystem paths are resolved as described in utils.ReadTextFile.

Parameters

NameTypeDescription
fileNamestring
reload_panel = falseoptionalboolean

If true, reloads panel script

Returns

boolean —

If false, then an error occurred during import. Also, if an error occurs during import, the panel does not reload.

method

NotifyOthers

jsdoc/window.js:464
NotifyOthers(name, info)

This will synchronously trigger on_notify_data(name, info) in other panels.
!!! Beware !!!: data passed via info argument must NOT be used or modified in the source panel after invoking this method.

Legacy compatibility API
Existing scripts can keep using NotifyOthers unchanged. For new asynchronous structured-clone messaging between panels and Workers, prefer BroadcastChannel.

Parameters

NameTypeDescription
namestring
info*

Example

let data = { 
   // some data
};
window.NotifyOthers('have_some_data', data);

data = null; // stop using the object immediately
// AddSomeAdditionalValues(data); // don't try to modify it, since it will affect the object in the other panel as well
method

RadioButtons

jsdoc/window.js:680
RadioButtons(buttons)

Creates a group of radio buttons. Takes an array of buttons as an argument. Each button must have at least two states, otherwise the function will fail.

Parameters

NameTypeDescription
buttonsArray<ButtonObject>

Throws

Error —

If buttons contains an invalid button object.

Example

var a = window.CreateButton(0 , 0, [path, hpath], null);
var b = window.CreateButton(30 ,0 , [path, hpath], null);
var c = window.CreateButton(60 ,0 , [path, hpath], null);
window.RadioButtons([a, b, c]);
// Now when you click on one button (state 1), the other will be switch to state 0 and vice versa.
method

Reload

jsdoc/window.js:484
Reload(clear_properties)

Reloads panel.

Parameters

NameTypeDescription
clear_properties = falseoptionalboolean

If true, all panel properties will be cleared before reload

method

RemoveButton

jsdoc/window.js:694
RemoveButton(button)

Removes a button

Parameters

NameTypeDescription
buttonButtonObject
method

Repaint

jsdoc/window.js:490
Repaint(force)

Performance note: don't force the repaint unless it's really necessary - repaint calls might be grouped up when *not forced* which will turn them into a single repaint call, thus reducing the amount of on_paint calls.

Parameters

NameTypeDescription
force = falseoptionalboolean

If true, will repaint immediately, otherwise a repaint task will be *scheduled*.

method

RepaintRect

jsdoc/window.js:499
RepaintRect(x, y, w, h, force)

Repaints a part of the screen.
Use this instead of Repaint on frequently updated areas such as time, bitrate, seekbar, etc.

Performance note: see Performance note in Repaint.

Parameters

NameTypeDescription
xnumber
ynumber
wnumber
hnumber
force = falseoptionalboolean

If true, will repaint immediately, otherwise a repaint task will be *scheduled*.

method

SetCursor

jsdoc/window.js:514
SetCursor(id)

This would usually be used inside the on_mouse_move callback.
Use -1 if you want to hide the cursor.

Parameters

NameTypeDescription
idnumber

See Flags for flags like IDC_ARROW

method

SetImePosition

jsdoc/window.js:522
SetImePosition(x, y)

Sets the text insertion point used to position system IME UI for a custom-drawn text field. Coordinates are in panel client pixels. The component does not track or move the insertion point automatically; call this again whenever your script moves its caret.

This method does not create or draw a system caret. It only supplies the current insertion position to the IME so handwriting/candidate UI can be placed near the field.

Parameters

NameTypeDescription
xnumber

Insertion-point x-coordinate.

ynumber

Insertion-point y-coordinate.

Example source

method

SetInterval

jsdoc/window.js:536
SetInterval(func, delay)

Parameters

NameTypeDescription
funcfunction()
delaynumber

Returns

number

Throws

Error —

If func is not callable or delay is zero.

method

SetProperties

jsdoc/window.js:547
SetProperties(values, reload_panel)

Set panel properties from input map and (optionally) reloads the panel script
Does NOT clear existing properties before setting.

Parameters

NameTypeDescription
valuesMap

Map of values to set

reload_panel = falseoptionalreload_panel

If true, reloads panel script after setting

Example

const values = new Map([["First value", 1], ["Second value", 2], ["Third value", 3]]);
window.SetProperties(values);
method

SetProperty

jsdoc/window.js:560
SetProperty(name, val)

Set property value.
Property will be removed, if val is undefined or null.

Property values are saved per panel instance and are remembered between foobar2000 restarts.

Note: leading and trailing whitespace are removed from property name.

Parameters

NameTypeDescription
namestring
valoptional*
method

SetShortcutFilter

jsdoc/window.js:573
SetShortcutFilter(enabled, type_only, suppress_children)

Sets panel shortcut filter.

Parameters

NameTypeDescription
enabled = trueoptionalboolean

If true filter is enabled. Suppresses player shortcuts depending on the following two parameters

type_only = trueoptionalboolean

If true suppresses only shortcuts that identified as user input (keyboard_shortcut_manager::is_typing_message from SDK used). If false ALL shortcuts are disabled for panel

suppress_children = falseoptionalboolean

If true suppresses also shortcuts for all JSplitter's children. Takes into account the parameter type_only only for DUI. For CUI alwas disables ALL shortcuts

method

SetTimeout

jsdoc/window.js:582
SetTimeout(func, delay)

Parameters

NameTypeDescription
funcfunction()
delaynumber

Returns

number

Throws

Error —

If func is not callable.

methoddeprecated

ShowConfigure

jsdoc/window.js:593
ShowConfigure()
Deprecated.

Show configuration window of current panel.
Deprecated: use ShowConfigureV2 to configure panel and EditScript to edit script.

method

ShowConfigureV2

jsdoc/window.js:604
ShowConfigureV2()

Show configuration window of current panel

method

ShowPanelList

jsdoc/window.js:610
ShowPanelList()

Show chidren panel list dialog for current panel

method

ShowProperties

jsdoc/window.js:616
ShowProperties()

Show properties window of current panel