WebRuntime
Static Members
timestamp(): Float| Returns |
|---|
| Float |
defaultConfig(): clay.RuntimeConfig| Returns |
|---|
| clay.RuntimeConfig |
Instance Members
gamepadsSupported: Boolwindow: WindowHandleThe runtime window canvas
webglVersion: FloatThe actual webgl version being used by the runtime
skipMouseEvents: BoolFor advanced usage: disable handling of mouse events
skipKeyboardEvents: BoolFor advanced usage: disable handling of keyboard events
init(): Voidready(): Voidrun(): Bool| Returns |
|---|
| Bool |
windowDevicePixelRatio(): Float| Returns |
|---|
| Float |
windowWidth(): Int| Returns |
|---|
| Int |
windowHeight(): Int| Returns |
|---|
| Int |
| Name | Type |
|---|---|
fullscreen |
Bool |
| Returns |
|---|
| Bool |
| Name | Type |
|---|---|
title |
String |
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 |
| Name | Type |
|---|---|
visible |
Bool |
startGamepadRumble(gamepadId: Int, lowFrequency: Float, highFrequency: Float, duration: Float): Void| Name | Type |
|---|---|
gamepadId |
Int |
lowFrequency |
Float |
highFrequency |
Float |
duration |
Float |
| Name | Type |
|---|---|
gamepadId |
Int |
| Name | Type |
|---|---|
index |
Int |
| Returns |
|---|
| String |
| Name | Type |
|---|---|
app |
clay.Clay |
Private Members
timestampStart: Floatinternal start time, allowing 0 based time values
webWindowId: IntThe window id to use for events
windowX: IntThe window x position. Internal, set by update_window_bounds
windowY: IntThe window y position. Internal, set by update_window_bounds
windowW: IntwindowH: IntwindowDpr: Floattouches: clay.IntMapkeyDownStates: ceramic.IntMap<Bool>didEmitTickOnce: BoolnextFrameCallbacks: Array<Function>rightButtonDown: BoolRight 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: FloatwheelAccY: FloatlayoutKeyCodes: MapKey codes of the physical keys with the current layout, as reported by the browser
keyboard layout map (navigator.keyboard.getLayoutMap(), Chromium and Electron).
pressedLayoutKeyCodes: MapKey codes of the physical keys with the current layout, learned from key presses (always right, but only known for keys pressed at least once).
Runtime loop, run at every frame
| Name | Type | Default |
|---|---|---|
t |
Float | 0.016 |
| Returns |
|---|
| Bool |
createWindow(): VoidcreateRenderContext(window: WindowHandle): Bool| Name | Type |
|---|---|
window |
WindowHandle |
| Returns |
|---|
| Bool |
createRenderContextFailed(): VoidapplyGLAttributes(config: clay.RenderConfig): js.html.webgl.ContextAttributes| Name | Type |
|---|---|
config |
clay.RenderConfig |
| Returns |
|---|
| js.html.webgl.ContextAttributes |
postRenderContext(window: WindowHandle): Void| Name | Type |
|---|---|
window |
WindowHandle |
setupEvents(): VoidgrabKeyboardFocus(): Void| Name | Type |
|---|---|
_ |
Dynamic |
handleContextMenu(ev: js.html.MouseEvent): Void| Name | Type |
|---|---|
ev |
js.html.MouseEvent |
syncRightButton(ev: js.html.MouseEvent): VoidEmit 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(): VoidhandleKeyDown(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.KeyCodeThis takes a DOM keycode and returns a clay KeyCode value
| Name | Type |
|---|---|
domKeyCode |
Int |
| Returns |
|---|
| clay.KeyCode |
convertScanCode(rawCode: String, keyCode: clay.KeyCode): clay.ScanCodeThis 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(): VoidinitGamepads(): VoidgetGamepadList(): 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(): VoidloadKeyboardLayout(): Void| Name | Type |
|---|---|
n |
Float |
| Returns |
|---|
| Float |
Metadata
| Name | Parameters |
|---|---|
:access |
clay.Clay |
:access |
clay.Input |
:access |
clay.Screen |