@witchcraft/spellcraft
    Preparing search index...

    Function setKeyProp

    • Sets a settable key property.

      You should not use this to set key state the manager manages (those tagged with

      Type Parameters

      • TEntries extends KeySetEntries
      • TProp extends keyof KeySetEntries
      • TEntry extends
            | {
                error: "CANNOT_SET_WHILE_DISABLED";
                hooks: GetKeyHooks<"pressed">;
                manager: PickManager<"options", "stringifier"> & Record<any, any> & Pick<
                    Manager,
                    "keys",
                >;
                val: boolean;
            }
            | {
                error: "CANNOT_SET_WHILE_DISABLED";
                hooks: GetKeyHooks<"toggleOnPressed">;
                manager: PickManager<"options", "stringifier"> & Record<any, any> & Pick<
                    Manager,
                    "keys",
                >;
                val: undefined
                | boolean;
            }
            | {
                error: "CANNOT_SET_WHILE_DISABLED";
                hooks: GetKeyHooks<"toggleOffPressed">;
                manager: PickManager<"options", "stringifier"> & Record<any, any> & Pick<
                    Manager,
                    "keys",
                >;
                val: undefined
                | boolean;
            }
            | {
                error: "KEY_IN_USE";
                hooks: GetKeyHooks<"enabled">;
                manager: BaseKeyManager;
                val: boolean;
            }
            | Unmanaged<"x">
            | Unmanaged<"y">
            | Unmanaged<"width">
            | Unmanaged<"height">
            | Unmanaged<"render">
            | Unmanaged<"classes">
            | Unmanaged<"label">
      • THooks extends Partial<Hooks>
      • TCheck extends boolean | "only" = true

      Parameters

      • key: Key

        Key is mutated if check is not "only".

      • prop: TProp
      • val: TEntry["val"]
      • manager: (TEntry["manager"] extends never ? unknown : TEntry["manager"]) & {
            hooks?: THooks;
        }
      • __namedParameters: { check?: TCheck } = {}

      Returns Result<
          TCheck extends "only" ? true : Key,

              | MultipleErrors<TEntry["error"]>
              | CanHookErrors<THooks extends never ? never : THooks, "canSetKeyProp">,
      >

      in the docs) unless you've forgone using the manager.

      Note that while the manager argument is always required, for unmanaged properties you can pass {} and for most others you can pass a partial manager if needed. This is because it's very difficult to keep the heavy per prop types and allow the manager to be optional in these cases.