UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

32 lines (22 loc) 741 B
import { TypeEditor } from "../../TypeEditor.js"; import EmptyView from "../../../../../src/view/elements/EmptyView.js"; export class StringEditor extends TypeEditor { build(parent, field, registry) { const ctrl = new EmptyView({ tag: 'input' }); ctrl.attr({ type: 'text' }); function sync_up() { ctrl.el.value = field.adapter.read(parent, field.name); } function sync_down() { const str = ctrl.el.value; field.adapter.write(parent, field.name, str); } ctrl.on.linked.add(sync_up); ctrl.el.addEventListener('input', sync_down); return ctrl; } }