HammeriteEditorCommand

Editor. Inherits RefCounted

One thing the editor can be asked to do, and how it is asked.

The point of these existing at all is that a keystroke used to be the only handle on a command: the binding, the label and the code were the same match branch, so nothing could list what the editor could do, show what a key was bound to, or say whether it would work right now.

Properties

TypeNameDefault
Callableaction
StringNameaction_id
boolbefore_tool
Callablechecked_predicate
StringName[]contexts
Callableenabled_predicate
StringNameid
Stringkeywords
Stringlabel
Callablelabel_provider
StringNamemenu
StringNameowner_tool
StringNameradio_group
Shortcutshortcut
Stringtyped

Methods

ReturnsMethod
Stringaccelerator_text()
HammeriteEditorCommandbound_also_to(keycode: int, command: bool = false, shift: bool = false, ctrl: bool = false, alt: bool = false)
HammeriteEditorCommandbound_to(keycode: int, command: bool = false, shift: bool = false, ctrl: bool = false, alt: bool = false)
HammeriteEditorCommandbound_to_mouse(button: int, command: bool = false, shift: bool = false, ctrl: bool = false, alt: bool = false)
HammeriteEditorCommandchecked_when(predicate: Callable)
Stringcommand_key_name() static
HammeriteEditorCommandcreate(command_id: StringName, command_label: String, command_action: Callable) static
Stringcurrent_label()
HammeriteEditorCommandenabled_when(predicate: Callable)
HammeriteEditorCommandin_context(names: StringName[])
HammeriteEditorCommandin_menu(m: StringName)
HammeriteEditorCommandin_radio_group(group: StringName)
boolis_checked()
boolis_enabled()
boolis_mac() static
boolis_toggle()
boolis_typed_by(event: InputEvent)
HammeriteEditorCommandlabelled_by(f: Callable)
HammeriteEditorCommandowned_by(tool_name: StringName)
HammeriteEditorCommandrunning_before_tools()
HammeriteEditorCommandruns_action(id: StringName)
HammeriteEditorCommandtyped_as(character: String)
HammeriteEditorCommandwith_keywords(words: String)

Property descriptions

action

var action: Callable

What it does.

action_id

var action_id: StringName

The entity action (get_actions()) this command runs, if it runs one. The context menu offers every action the selection has that no command already covers, and this is how it knows which those are - otherwise Trigger is drawn twice, once from the table and once from the entity.

before_tool

var before_tool: bool

Runs before the active tool sees the event, rather than after. Narrowing does: it is how you get out of a narrowed view, and a tool holding the keyboard must not be able to trap you in one.

checked_predicate

var checked_predicate: Callable

For a toggle, asked whether it is on now; unset means it is not a toggle. Ask through is_checked().

contexts

var contexts: StringName[]

Which right-click contexts offer this command, by HammeriteEditorCommands CTX_* name. Empty means the context menu never draws it. A command may name several: mirroring applies to a brush and to an entity alike.

enabled_predicate

var enabled_predicate: Callable

Asked whether it can be done right now: greys the menu item and refuses the keystroke. Unset means always. Ask through is_enabled().

id

var id: StringName

Stable name, for menus and addons to refer to a command by. Not shown to anyone.

keywords

var keywords: String

Other words an author might look for this command by in the launcher, when theirs is not the label's: "join" for merging.

label

var label: String

What a menu calls it, drawn as given: pass it already translated (tr("...")), as the editor's own table does.

label_provider

var label_provider: Callable

Asked what this command calls itself right now, when that depends on state - "Resume Simulation" once something is paused. Unset means label. Ask through current_label().

menu

var menu: StringName

Which menu it belongs under, or empty for a command with a key and no menu entry.

owner_tool

var owner_tool: StringName

Non-empty means the binding belongs to that tool and is never dispatched globally - the tool asks for it by id while it is running. This is how Space can be "toggle selected lights" everywhere and "cycle clip mode" inside the clip tool without the two fighting.

radio_group

var radio_group: StringName

Non-empty makes this one option among several - the visualization modes - drawn as a radio item.

shortcut

var shortcut: Shortcut

What it is bound to: every key and click bound_to() and bound_to_mouse() added, the first of them drawn down the menu's right-hand side.

typed

var typed: String

A character that runs it when typed with no Cmd, Ctrl or Alt held, whatever key the layout puts it on: / is Shift-7 on a Nordic keyboard, and a binding to the slash KEY never fired there.

Method descriptions

accelerator_text()

func accelerator_text() -> String

The keystroke, as a person would write it. For the menu, and for anything that has to say what a command is bound to without a menu to draw it in.

bound_also_to()

func bound_also_to(keycode: int, command: bool = false, shift: bool = false, ctrl: bool = false, alt: bool = false) -> HammeriteEditorCommand

The same as bound_to(), for a table that reads better saying so.

bound_to()

func bound_to(keycode: int, command: bool = false, shift: bool = false, ctrl: bool = false, alt: bool = false) -> HammeriteEditorCommand

Bind a keystroke to it, beside any it has: the numpad's Enter as well as Enter, say. command is Cmd on macOS and Ctrl elsewhere. ctrl is Ctrl on macOS and Alt elsewhere, because there Ctrl is already taken by command and the Windows key is the system's.

bound_to_mouse()

func bound_to_mouse(button: int, command: bool = false, shift: bool = false, ctrl: bool = false, alt: bool = false) -> HammeriteEditorCommand

Bind a click to it, beside any key or click it has: Alt+click and the like. No menu draws these, but they are bindings and they live in the table with the rest rather than in a second place.

checked_when()

func checked_when(predicate: Callable) -> HammeriteEditorCommand

Makes this a toggle, ticked while predicate (no arguments, returns a bool) says so.

command_key_name()

static func command_key_name() -> String

What the command key is called here, for text that names it.

create()

static func create(command_id: StringName, command_label: String, command_action: Callable) -> HammeriteEditorCommand

A native class is made with no arguments, so this stands in for new(command_id, command_label, command_action).

current_label()

func current_label() -> String

What to draw it as. Asked at the moment a menu opens, never cached: a label that depends on state is only true for as long as the state is.

enabled_when()

func enabled_when(predicate: Callable) -> HammeriteEditorCommand

Sets enabled_predicate: predicate takes no arguments and returns a bool.

in_context()

func in_context(names: StringName[]) -> HammeriteEditorCommand

Offer this command when the right-click lands on one of names. See CTX_* on HammeriteEditorCommands.

in_menu()

func in_menu(m: StringName) -> HammeriteEditorCommand

Files the command under menu m (see the menu names on HammeriteEditorCommands). Like every builder here it returns the command itself, so a table of commands reads as a table rather than as thirty blocks of assignment.

in_radio_group()

func in_radio_group(group: StringName) -> HammeriteEditorCommand

Sets radio_group. Ticked as checked_when() says, like any toggle.

is_checked()

func is_checked() -> bool

Whether a toggle is on now: asks checked_predicate, and false when that is unset.

is_enabled()

func is_enabled() -> bool

Whether it can be run now: asks enabled_predicate, and true when that is unset.

is_mac()

static func is_mac() -> bool

Whether the editor is on a Mac, where Cmd is the command key. The web build asks the browser.

is_toggle()

func is_toggle() -> bool

Whether this is a toggle at all: whether it has a checked_predicate.

is_typed_by()

func is_typed_by(event: InputEvent) -> bool

Whether event types typed.

labelled_by()

func labelled_by(f: Callable) -> HammeriteEditorCommand

Sets label_provider: f takes no arguments and returns the label, or an empty string to fall back on label.

owned_by()

func owned_by(tool_name: StringName) -> HammeriteEditorCommand

Makes the binding tool_name's alone; see owner_tool. The tool asks for it with HammeriteEditorCommands.is_event_for().

running_before_tools()

func running_before_tools() -> HammeriteEditorCommand

Sets before_tool.

runs_action()

func runs_action(id: StringName) -> HammeriteEditorCommand

Sets action_id.

typed_as()

func typed_as(character: String) -> HammeriteEditorCommand

Also run by typing character - see typed.

with_keywords()

func with_keywords(words: String) -> HammeriteEditorCommand

Sets keywords.

Hammerite 2.0 · built from 6d57ab2d, 2026-10-17