InputPlugin

View source

ExtendsPlugin

Provides keyboard, mouse, and touch input for an App through one plugin registration.

InputPlugin combines KeyboardPlugin, MousePlugin, and TouchPlugin into a single input stack. Use it when an app needs these device inputs together; use the individual plugins when it needs only part of the stack.

The optional target value is retained as input configuration and defaults to document.body. Browser event delivery is provided through the window layer.

The stack expects CorePlugin, ReflectPlugin, MathPlugin, and WindowPlugin to be registered before App#run. These dependencies are not installed automatically by InputPlugin.

Examples

import { App } from '@wimaengine/app'
import { CommandsPlugin } from '@wimaengine/command'
import { CorePlugin } from '@wimaengine/core'
import { InputPlugin } from '@wimaengine/input'
import { MathPlugin } from '@wimaengine/math'
import { ReflectPlugin } from '@wimaengine/reflect'
import { WindowPlugin } from '@wimaengine/window'

const input = new InputPlugin()
// In a browser, input.target defaults to document.body.

new App()
  .registerPlugin(new ReflectPlugin())
  .registerPlugin(new CorePlugin())
  .registerPlugin(new MathPlugin())
  .registerPlugin(new CommandsPlugin())
  .registerPlugin(new WindowPlugin())
  .registerPlugin(input)
  .run()

Constructor


constructor(target?: HTMLElement)

View source

Creates the input plugin configuration.

The value is stored as provided. The default expression reads document.body, so omitting target requires a browser document to be available.

Parameters

NameDescriptionDefault
target?

DOM element to retain as the plugin target.

document.body

Properties


target: HTMLElement

View source

DOM element retained as this plugin’s target configuration.

The constructor defaults this field to document.body. The current register implementation does not use the field or forward it to TouchPlugin, MousePlugin, or KeyboardPlugin.

Methods


register(app: App): void

View source

Adds the touch, mouse, and keyboard plugins to the app.

The child plugins are added in touch, mouse, keyboard order. This method does not read this.target; the child plugins obtain their event data through the window event resources registered by the window layer.

Parameters

NameDescriptionDefault
app——