WebRuntime

clay.base.BaseRuntime → clay.web.WebRuntime (Class)

Static Members

timestamp(): Float
Returns
Float

defaultConfig(): clay.RuntimeConfig
Returns
clay.RuntimeConfig

Instance Members

gamepadsSupported: Bool

The runtime window canvas


webglVersion: Float

The actual webgl version being used by the runtime


skipMouseEvents: Bool

For advanced usage: disable handling of mouse events


skipKeyboardEvents: Bool

For advanced usage: disable handling of keyboard events


init(): Void

ready(): Void

run(): Bool
Returns
Bool

windowDevicePixelRatio(): Float
Returns
Float

windowWidth(): Int
Returns
Int

windowHeight(): Int
Returns
Int

setWindowFullscreen(fullscreen: Bool): Bool
Name Type
fullscreen Bool
Returns
Bool

setWindowTitle(title: String): Void
Name Type
title String

keyCodeForScanCode(scanCode: Int): Int

Key code produced by the physical key scanCode with the current keyboard layout (the letter printed on that key), or 0 if unknown.

Name Type
scanCode Int
Returns
Int

setCursorVisible(visible: Bool): Void
Name Type
visible Bool

startGamepadRumble(gamepadId: Int, lowFrequency: Float, highFrequency: Float, duration: Float): Void
Name Type
gamepadId Int
lowFrequency Float
highFrequency Float
duration Float

stopGamepadRumble(gamepadId: Int): Void
Name Type
gamepadId Int

getGamepadName(index: Int): String
Name Type
index Int
Returns
String

new(app: clay.Clay): Void
Name Type
app clay.Clay

Private Members

timestampStart: Float

internal start time, allowing 0 based time values


webWindowId: Int

The window id to use for events


windowX: Int

The window x position. Internal, set by update_window_bounds


windowY: Int

The window y position. Internal, set by update_window_bounds


windowW: Int

windowH: Int

windowDpr: Float

touches: clay.IntMap

gamepadButtonCache: Array<Array<Float>>

gamepadAxisCache: Array<Array<Float>>

pendingKeyUps: Array<Dynamic>

keyDownStates: ceramic.IntMap<Bool>

didEmitTickOnce: Bool

nextFrameCallbacks: Array<Function>

rightButtonDown: Bool

Right mouse button state as seen by clay.

Chromium 130 on macOS (Electron 33) dispatches mousedown and contextmenu for the right button and nothing else: no mouseup, no pointerup, no auxclick, and no event at all while the button is held. Chromium 112 (Electron 24) still dispatched the release. A right button drag is therefore impossible there, but the button state can still be kept consistent: the release is emitted as soon as a mouse event reports the button as no longer held (see syncRightButton()).


wheelAccX: Float

wheelAccY: Float

layoutKeyCodes: Map

Key codes of the physical keys with the current layout, as reported by the browser keyboard layout map (navigator.keyboard.getLayoutMap(), Chromium and Electron).


pressedLayoutKeyCodes: Map

Key codes of the physical keys with the current layout, learned from key presses (always right, but only known for keys pressed at least once).


loop(?t: Float = 0.016): Bool

Runtime loop, run at every frame

Name Type Default
t Float 0.016
Returns
Bool

createWindow(): Void

createRenderContext(window: WindowHandle): Bool
Name Type
window WindowHandle
Returns
Bool

createRenderContextFailed(): Void

Name Type
config clay.RenderConfig
Returns
js.html.webgl.ContextAttributes

postRenderContext(window: WindowHandle): Void
Name Type
window WindowHandle

setupEvents(): Void

grabKeyboardFocus(): Void

handleVisibilityChange(_: Dynamic): Void
Name Type
_ Dynamic

handleContextMenu(ev: js.html.MouseEvent): Void
Name Type
ev js.html.MouseEvent

syncRightButton(ev: js.html.MouseEvent): Void

Emit the release of the right mouse button when an event reports it as no longer held. Needed because some browsers never deliver its mouseup (see rightButtonDown). Where the release is delivered normally, buttons still reports the button as held during a drag, so this changes nothing and the real mouseup ends the gesture.

Name Type
ev js.html.MouseEvent

handleFullscreenChange(ev: js.html.Event): Void
Name Type
ev js.html.Event

handleFullscreenError(ev: js.html.Event): Void
Name Type
ev js.html.Event

handleMouseEnter(ev: js.html.MouseEvent): Void
Name Type
ev js.html.MouseEvent

handleMouseLeave(ev: js.html.MouseEvent): Void
Name Type
ev js.html.MouseEvent

handleMouseDown(ev: js.html.MouseEvent): Void
Name Type
ev js.html.MouseEvent

handleMouseUp(ev: js.html.MouseEvent): Void
Name Type
ev js.html.MouseEvent

handleMouseMove(ev: js.html.MouseEvent): Void
Name Type
ev js.html.MouseEvent

handleWheel(ev: js.html.WheelEvent): Void
Name Type
ev js.html.WheelEvent

handleTouchStart(ev: js.html.TouchEvent): Void
Name Type
ev js.html.TouchEvent

handleTouchEnd(ev: js.html.TouchEvent): Void
Name Type
ev js.html.TouchEvent

handleTouchMove(ev: js.html.TouchEvent): Void
Name Type
ev js.html.TouchEvent

clearPendingKeyUps(): Void

handleKeyDown(ev: js.html.KeyboardEvent): Void
Name Type
ev js.html.KeyboardEvent

handleKeyUp(ev: js.html.KeyboardEvent): Void
Name Type
ev js.html.KeyboardEvent

handleKeyPress(ev: js.html.KeyboardEvent): Void
Name Type
ev js.html.KeyboardEvent

handleGamepadConnected(ev: js.html.GamepadEvent): Void
Name Type
ev js.html.GamepadEvent

handleGamepadDisconnected(ev: js.html.GamepadEvent): Void
Name Type
ev js.html.GamepadEvent

convertKeyCode(domKeyCode: Int): clay.KeyCode

This takes a DOM keycode and returns a clay KeyCode value

Name Type
domKeyCode Int
Returns
clay.KeyCode

convertScanCode(rawCode: String, keyCode: clay.KeyCode): clay.ScanCode

This taks a KeyboardEvent.code value and returns a clay ScanCode value

Name Type
rawCode String
keyCode clay.KeyCode
Returns
clay.ScanCode

modStateFromEvent(keyEvent: js.html.KeyboardEvent): clay.ModState
Name Type
keyEvent js.html.KeyboardEvent
Returns
clay.ModState

getWindowX(bounds: js.html.DOMRect): Int
Name Type
bounds js.html.DOMRect
Returns
Int

getWindowY(bounds: js.html.DOMRect): Int
Name Type
bounds js.html.DOMRect
Returns
Int

translateMouseX(ev: js.html.MouseEvent): Int
Name Type
ev js.html.MouseEvent
Returns
Int

translateMouseY(ev: js.html.MouseEvent): Int
Name Type
ev js.html.MouseEvent
Returns
Int

updateWindowBounds(): Void

initGamepads(): Void

getGamepadList(): Array<js.html.Gamepad>
Returns
Array<js.html.Gamepad>

initGamepadCacheIfNeeded(gamepad: js.html.Gamepad): Void
Name Type
gamepad js.html.Gamepad

deleteGamepadCache(gamepad: js.html.Gamepad): Void
Name Type
gamepad js.html.Gamepad

pollGamepads(): Void

loadKeyboardLayout(): Void

clamp(n: Float): Float
Name Type
n Float
Returns
Float

Metadata

Name Parameters
:access clay.Clay
:access clay.Input
:access clay.Screen