Bindings
Classes in the Phui\Bindings namespace. A binding pairs an input with a handler, and is returned from a component's bindings().
Binding
final readonly class Phui\Bindings\Binding
static keypress(
Keypress|array|null $keys,
?Closure $handler = null,
array $modifiers = [],
string $description = '',
bool $global = false,
): selfBinds one or more Keypress values. $global matches regardless of which component holds focus. $description is the text shown in a Keymap.
Binding::keypress(
Keypress::ENTER,
fn () => $this->submit(),
description: 'Submit',
)static focus(
Keypress|array $keys,
array $modifiers = [],
string $description = '',
bool $global = true,
): selfBinds keys that move focus to the declaring component. Global by default.
static paste(Closure $handler): self
static mouseDown(Closure $handler): self
static mouseUp(Closure $handler): self
static scroll(Closure $handler): selfBind a handler to a paste, mouse-button press, mouse-button release or scroll event.
static none(
Keypress|array|null $keys = null,
array $modifiers = [],
): selfRemoves a binding that a component declared, used from a parent's bindings() override.
label(): stringReturns the binding's keys as display text, each prefixed with its modifiers joined by +, and alternatives separated by /.
Keymap
final readonly class Phui\Bindings\Keymap
The bindings a keypress would currently resolve against, returned by $this->keymaps->active().
__construct(public array $entries = [])Creates a keymap from an array of entries.
isEmpty(): boolReturns whether the keymap has no entries.
FrameworkBindings
final class Phui\Bindings\FrameworkBindings
The bindings the framework supplies itself, configured on the Screen.
__construct(
public ?Binding $focusNext = null,
public ?Binding $focusPrevious = null,
public ?Binding $toggleDebug = null,
public ?Binding $quit = null,
)Creates a set of framework bindings. A null entry keeps the default.
Keypress
enum Phui\Events\Keyboard\Keypress: string
Every key the runtime recognises.
label(): stringReturns the case's display text.
static fromCharacter(string $char): ?selfReturns the case matching $char, or null when none does.
Cases
| Group | Cases |
|---|---|
| Modifiers | SHIFT, CTRL, ALT, META, CMD |
| Letters | a to z, A to Z |
| Digits | ZERO to NINE |
| Navigation | ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, HOME, END, PAGE_UP, PAGE_DOWN |
| Function | F1 to F20 |
| Editing | ENTER, TAB, BACKSPACE, DELETE, INSERT, ESCAPE, SPACE |
| Punctuation | PERIOD, COMMA, SEMICOLON, COLON, SLASH, BACKSLASH, QUOTE, DOUBLE_QUOTE, BACKTICK, TILDE, MINUS, UNDERSCORE, PLUS, EQUALS, PIPE, QUESTION, EXCLAMATION |
| Symbols | AT, HASH, DOLLAR, PERCENT, CARET, AMPERSAND, ASTERISK, LESS_THAN, GREATER_THAN |
| Brackets | PAREN_LEFT, PAREN_RIGHT, BRACKET_LEFT, BRACKET_RIGHT, BRACE_LEFT, BRACE_RIGHT |