UNPKG

shimi

Version:

A JS framework for building complex MIDI applications

58 lines (57 loc) 2.69 kB
import PropertyTracker from './PropertyTracker'; import ShimiEvent, { ShimiEventData } from './ShimiEvent'; /** * The ButtonEventData class extends ShimiEventData. It contains a reference to the source ButtonInput that created the event. * * @category User Inputs */ export declare class ButtonEventData extends ShimiEventData<ButtonInput> { constructor(source: ButtonInput); } /** * The ButtonEvent class extends ShimiEvent, providing an object which can be subscribed to. * * When the event is fired, it calls all subscribed event handlers, passing in a ButtonEventData object containing information about the button that triggered the event. * * @category User Inputs */ export declare class ButtonEvent extends ShimiEvent<ButtonEventData, ButtonInput> { } /** * The ButtonInput class models a button which can be pressed or released. Pressure-sensitive buttons are also supported, with changes in pressure announced through the `changed` ButtonEvent. * * @category User Inputs */ export default class ButtonInput { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** Tracks changes to the button's state. */ valueTracker: PropertyTracker<number>; /** Returns the current value of the button. */ get value(): number; /** Returns whether the button is currently pressed. */ get isPressed(): boolean; /** The name property allows for an easy way to identify a button when it may be one of many buttons available. */ get name(): string; private _name; /** Returns how many consecutive milliseconds the button has been held pressed for. If the button is not currently pressed, this will return 0. */ get activeMs(): number; private _activeMs; /** This event is fired every time the button switches state from not being pressed, to being pressed. */ pressed: ButtonEvent; /** This event is fired every time the button switches state from being pressed, to not being pressed. */ released: ButtonEvent; /** This event is fired every time the button remains being pressed, but changes how hard it's being pressed. */ changed: ButtonEvent; /** * @param name The name property allows for an easy way to identify a button when it may be one of many buttons available. */ constructor(name: string); /** * This method is intended to be called by a clock to provide regular updates. It should not be called by consumers of the library. * @param deltaMs How many milliseconds have passed since the last update cycle. * @returns */ update(deltaMs: number): void; }