# Custom Windows

This type of object represents a window that you create via mainWindow.createMediaWindow. It's a specialization of the basic Window Objects that the system provides for the main playfield window, the backglass window, and so forth. You can use custom windows to supplement the standard set of windows if you have additional media types that you want to display, or to display entirely custom graphics using Drawing Layers.

For some examples of how to create your own custom windows, see Custom Media Window in the Worked Examples section.

## Class inheritance structure

Basic Window Object →
Secondary Window →
Custom Window

## Event target

A custom window object is an event target, so you can use the standard event methods (on(), off(), addEventListener(), etc) to add and remove event listeners. See EventTarget. This window receives the following event types:

## Properties and methods

Since Custom Windows inherit from the Secondary Window base class, they have all of the methods and properties that a Secondary Window has, as described in Secondary Windows. That class is itself a subclass of the basic common window class, so a Custom Window also has the standard window functions, described in Window Objects.

In addition to the inherited functionality, Custom windows also have some extended functions of their own, as listed below.

showMediaWhenRunningFlag: This property lets you control whether or not the window continues to show media while a game is running. This is the custom window equivalent of the options dialog checkboxes that let you control the same behavior for the built-in windows. This can take on three possible values:

- true means that the window continues to show its media while a game is running
- false means that the window is blanked out and sent to the background while a game is running. This is the default behavior for custom windows, and it's also the default for all of the system windows, except when you override it using the options settings (the "Keep showing this game's media while running" checkboxes in the Game Details box, the system setup options pages, and the Launch options page).
- undefined means that the normal "key" mechanism is used. The system windows use the key to store the per-game, per-system, and global preferences set through the various settings dialogs, by checking the status of the key in the global settings file and the Game Stats file. If you defined a key for this window when creating it (see showMediaWhenRunningKey undef mainWindow.createMediaWindow()), the system uses the same key search for this custom window. If you didn't define a key string for the window when creating it, undefined has the same meaning as false, yielding the default behavior of blanking out the window while a game is running.

Note that values of true and false override any "key" lookup, so you can use these to control the behavior unconditionally in Javascript code. For example, you could use a gameselect event to decide on how to handle the window for the current game each time a new game is selected, setting showMediaWhenRunningFlag to the desired value.