CAction
Represents a reusable user action with text, icon, enabled and checked state.
import { CAction } from "canvas-toolkit-lib";Declared members
readonly changed: CSignal<[]>;Emitted when an action property changes.
readonly triggered: CSignal<[]>;Emitted when the action is triggered.
readonly toggled: CSignal<[boolean]>;Emitted when the checked state changes. @param checked New checked state.
constructor(text?: string, shortcutParent?: CWidget | null);Creates an action. @param text Initial display text.
shortcut(): string;Shortcut active in shortcutParent() and its descendants.
setShortcut(key: string): void;shortcutParent(): CWidget | null;setShortcutParent(parent: CWidget | null): void;Assigns one explicit scope shared by all presentations of this action.
destroy(): void;Releases the keyboard binding. Menus and toolbars do not own actions.
text(): string;Returns the action text. @returns Current display text.
setText(text: string): void;Sets the action text. @param text New display text.
icon(): CIcon | null;Returns the action icon. @returns Current icon, or `null` if no icon is set.
setIcon(icon: CIcon | null): void;Sets the action icon. @param icon New icon, or `null` to remove it.
isEnabled(): boolean;Returns whether the action can be triggered. @returns `true` if the action is enabled.
setEnabled(enabled: boolean): void;Sets whether the action can be triggered. @param enabled New enabled state.
isCheckable(): boolean;Returns whether the action has a checked state. @returns `true` if the action is checkable.
setCheckable(checkable: boolean): void;Sets whether the action has a checked state. Disabling checkability also clears the checked state. @param checkable New checkable state.
isChecked(): boolean;Returns the current checked state. @returns `true` if the action is checked.
setChecked(checked: boolean): void;Sets the checked state of a checkable action. @param checked New checked state.
trigger(): void;Triggers the action if it is enabled. Checkable actions toggle their checked state first.