UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

30 lines (24 loc) 784 B
import { TypeEditor } from "../../TypeEditor.js"; import ButtonView from "../../../../../src/view/elements/button/ButtonView.js"; export class FunctionEditor extends TypeEditor { build(parent, field, registry) { if (field.schema === undefined) { // no schema, function editors are only available for explicit schema return undefined; } /** * @type {Function} */ const v = field.adapter.read(parent, field.name); if (typeof v !== "function") { // wrong type return undefined; } return new ButtonView({ action: () => { v.call(parent); }, name: 'execute' }); } }