Cosmic Docs

Theme
cs.window

Window Management

Provides a cross platform API to create and manage windows.

cs.window.create width: number, height: number, title: string ) object

Creates a new window and returns the handle.

An interface for a window handle.

Returns the graphics context attached to this window.

cs.window.WindowonUpdate callback: ?function )

Provide the handler for the window's frame updates. Provide a null value to disable these events. This is a good place to do your app's update logic and draw to the screen. The frequency of frame updates is limited by an FPS counter. Eventually, this frequency will be configurable.

cs.window.WindowonMouseDown callback: ?function )

Provide the handler for receiving mouse down events when this window is active. Provide a null value to disable these events.

cs.window.WindowonMouseUp callback: ?function )

Provide the handler for receiving mouse up events when this window is active. Provide a null value to disable these events.

cs.window.WindowonMouseMove callback: ?function )

Provide the handler for receiving mouse move events when this window is active. Provide a null value to disable these events.

cs.window.WindowonKeyDown callback: ?function )

Provide the handler for receiving key down events when this window is active. Provide a null value to disable these events.

cs.window.WindowonKeyUp callback: ?function )

Provide the handler for receiving key up events when this window is active. Provide a null value to disable these events.

cs.window.WindowonResize callback: ?function )

Provide the handler for the window's resize event. Provide a null value to disable these events. A window can be resized by the user or the platform's window manager.

Returns how long the last frame took in microseconds. This includes the onUpdate call and the delay to achieve the target FPS. This is useful for animation or physics for calculating the next position of an object.

Returns how long the last frame took to perform onUpdate in microseconds. This is useful to measure the performance of your onUpdate logic.

Returns the average frames per second.

Closes the window and frees the handle.

Minimizes the window.

Maximizes the window. The window must be resizable.

Restores the window to the size before it was minimized or maximized.

Set to fullscreen mode with a videomode change.

Set to pseudo fullscreen mode which takes up the entire screen but does not change the videomode.

Set to windowed mode.

cs.window.WindowcreateChild title: string, width: number, height: number ) object

Creates a child window attached to this window. Returns the new child window handle.

cs.window.Windowposition x: number, y: number )

Sets the window position on the screen.

Center the window on the screen.

Raises the window above other windows and acquires the input focus.

Returns the width of the window in logical pixel units.

Returns the height of the window in logical pixel units.

cs.window.WindowsetTitle title: string )

Sets the window's title.

Gets the window's title.

cs.window.Windowresize width: number, height: number )

Resizes the window.