window#
Properties
| window.DPI | number |
read | This value is fixed when foobar2000 starts. It will not change even if Windows display settings are updated. |
| window.Height | number |
read | |
| window.IsDark | boolean |
read | |
| window.IsVisible | boolean |
read | Only returns false when panel is hidden in a tab. When covered by other windows, it still returns true. |
| window.MaxHeight | number |
read, write | |
| window.MaxWidth | number |
read, write | |
| window.MinHeight | number |
read, write | |
| window.MinWidth | number |
read, write | |
| window.Name | string |
read | Script name that was suuplied to window.DefineScript. |
| window.Width | number |
read |
Methods
window.ClearInterval(timerID)#
| Arguments | ||
|---|---|---|
| timerID | number |
No return value.
window.ClearTimeout(timerID)#
| Arguments | ||
|---|---|---|
| timerID | number |
No return value.
window.CreatePopupMenu()#
Returns a JsMenuObj instance.
window.CreateTooltip([font_name, font_size_px)#
| Arguments | ||
|---|---|---|
| font_name | string |
Default Segoe UI. |
| font_size_px | number |
Default 16. |
Returns a JsTooltip instance.
window.DefineScript(name[, options])#
| Arguments | ||
|---|---|---|
| name | string |
This will be available via window.Name. |
| options | object |
Empty by default. |
The options object may contain an author and version as strings.
Example
window.DefineScript('Properties', {author:'marc2003'});
Additionally, you can supply a features object containing grab_focus and drag_n_drop
which are boolean values. You would want to enable drag_n_dropto receive incoming files
in a playlist viewer.
Example
window.DefineScript(
'JS Playlist', {
author : 'Br3tt aka Falstaff',
features : {
drag_n_drop : true,
grab_focus : true
}
}
);
window.GetUIColour(type)#
| Arguments | ||
|---|---|---|
| type | ColourType |
Returns a number which can used as the colour in many methods.
window.GetUIFont(type)#
| Arguments | ||
|---|---|---|
| type | FontType |
Returns a string. See fonts.
window.GetProperty(name[, default_value])#
| Arguments | ||
|---|---|---|
| name | string |
|
| default_value | string,number,boolean |
Default null. |
Returns the value of name from the panel properties. If no value is
present and default_value is not null or undefined, it will be
stored and returned.
Example
include(fb.ComponentPath + 'helpers.js');
var default_colour = RGB(255, 0, 0);
// Default colour is used on first run, otherwise colour
// saved on previous use.
var colour = window.GetProperty('BASIC.COLOUR.PICKER.COLOUR', default_colour);
function on_paint(gr) {
gr.Clear(colour);
gr.FillRectangle(0, 0, window.Width, 24, RGB(0, 0, 0));
gr.WriteText('Click to open ColourPicker', '', RGB(255, 255, 255), 0, 0, window.Width, 24, 2, 0);
}
function on_mouse_lbtn_up() {
colour = utils.ColourPicker(colour);
/*
Save the new colour and it will be read the next
time the script starts. These properties are stored
as part of your layout either in theme.fth (Default UI)
or foo_ui_columns.cfg (Columns UI),
*/
window.SetProperty('BASIC.COLOUR.PICKER.COLOUR', colour);
window.Repaint();
}
window.NotifyOthers(name, info)#
| Arguments | ||
|---|---|---|
| name | string |
|
| info | string, number, array, object |
Listen for notifications in other panels with on_notify_data.
window.Reload([clear_properties])#
| Arguments | ||
|---|---|---|
| clear_properties | boolean |
Default false. |
No return value.
window.Repaint()#
No return value.
window.RepaintRect(x, y, w, h)#
No return value.
Note
Use this instead of window.Repaint on frequently updated areas
such as time, bitrate, seekbar, etc.
window.SetCursor(id)#
| Arguments | ||
|---|---|---|
| id | SetCursorID | Use -1 if you want to hide the cursor. |
No return value.
Note
This would usually be used inside the on_mouse_move callback.
window.SetInterval(func, delay)#
| Arguments | ||
|---|---|---|
| function | function |
|
| delay | number |
milliseconds |
The return value is the timerID which can be used
to cancel it.
Creates a timer that will run indefinitely unless cancelled.
Example
// This runs every 500ms forever because the return
// was ignored!
window.SetInterval(function () {
// do something
}, 500);
No return value.
window.SetPlaylistSelectionTracking()#
No return value.
Sets selected items to the active playlist selection and enables tracking. When the playlist selection changes, the stored selection is automatically updated.
Example
// Playlist view example
function on_focus(is_focused) {
if (is_focused) {
// Updates the selection when panel regains focus
// but not on every click
window.SetPlaylistSelectionTracking();
}
}
window.SetPlaylistTracking()#
No return value.
window.SetProperty(name, value)#
| Arguments | ||
|---|---|---|
| name | string |
|
| value | string,number,boolean |
No return value.
Sets a persistent property value. To remove an existing property, you
can supply null as the value.
See window.GetProperty for an example.
window.SetSelection(handle_list[, type])#
| Arguments | ||
|---|---|---|
| handle_list | JsMetadbHandleList | |
| type | SelectionType | Default 0. |
Example
// Library viewer example
function on_mouse_lbtn_up(x, y) {
// Presumably going to select something here...
handle_list = ...;
window.SetSelection(handle_list, 6);
}
window.SetTimeout(func, delay)#
| Arguments | ||
|---|---|---|
| function | function |
|
| delay | number |
milliseconds |
The return value is the timerID which can be used
to cancel it.
Example
window.SetTimeout(function () {
// code here will run after 10 seconds, once.
}, 10000);
window.ShowConfigure()#
No return value.
Shows the Configuration Window.
window.ShowProperties()#
No return value.
Shows the Properties Window of the current panel.