@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
42 lines • 1.83 kB
JavaScript
import { RegisterClass } from "../../../Misc/typeStore.js";
import { RichTypeBoolean } from "../../flowGraphRichTypes.js";
import { FlowGraphKeyboardEventBlock } from "./flowGraphKeyboardEventBlock.js";
/**
* A keyboard event block that fires when a key is pressed down.
* Extends {@link FlowGraphKeyboardEventBlock} with an `isRepeat` output
* and an `ignoreRepeat` configuration option.
*/
export class FlowGraphKeyDownEventBlock extends FlowGraphKeyboardEventBlock {
/**
* Creates a new FlowGraphKeyDownEventBlock.
* @param config optional configuration
*/
constructor(config) {
super(config);
/** @internal */
this.type = "KeyDown" /* FlowGraphEventType.KeyDown */;
this.isRepeat = this.registerDataOutput("isRepeat", RichTypeBoolean);
}
/** @internal */
_executeEvent(context, keyboardInfo) {
const repeat = keyboardInfo.event.repeat ?? false;
// Skip auto-repeat events when configured to do so.
if (repeat && this.config?.ignoreRepeat) {
return true;
}
// Set the repeat output before delegating to the base class,
// which calls _execute() and fires signals — downstream blocks
// must see the correct value during that execution chain.
this.isRepeat.setValue(repeat, context);
// Delegate to the base class for key filtering, output population, and execution.
return super._executeEvent(context, keyboardInfo);
}
/**
* @returns class name of the block.
*/
getClassName() {
return "FlowGraphKeyDownEventBlock" /* FlowGraphBlockNames.KeyDownEvent */;
}
}
RegisterClass("FlowGraphKeyDownEventBlock" /* FlowGraphBlockNames.KeyDownEvent */, FlowGraphKeyDownEventBlock);
//# sourceMappingURL=flowGraphKeyDownEventBlock.js.map