Events
Classes in the Phui\Events namespace. Events are passed to the handlers registered by bindings and by the mouse setters on nodes.
Event
abstract readonly class Phui\Events\Event
Extended by every event.
public string $rawThe bytes the event was parsed from.
getEventType(): stringReturns the identifier the event is routed by.
KeypressEvent
final readonly class Phui\Events\Keyboard\KeypressEvent extends Event
public string $key
public array $modifiers
public bool $isSpecialThe key pressed, the Keypress modifiers held with it, and whether the key is a named key rather than a character.
isChar(string $char): boolReturns whether the event is the given character.
hasModifier(Keypress $modifier): boolReturns whether the modifier was held.
PasteEvent
final readonly class Phui\Events\Keyboard\PasteEvent extends Event
public string $contentThe pasted text.
MouseEvent
abstract readonly class Phui\Events\Mouse\MouseEvent extends Event
Extended by every mouse event.
public int $x
public int $yThe pointer's position in screen cells.
public array $modifiersThe Keypress modifiers held.
public ?Point $contentPositionThe position relative to the handling element's content box, or null before the event reaches an element.
abstract atContentPosition(Point $position): staticReturns a copy carrying a content-relative position.
MouseClickEvent
final readonly class Phui\Events\Mouse\MouseClickEvent extends MouseEvent
public string $button
public bool $isPressWhich button the event came from, and whether it is a press rather than a release.
const LEFT = 'left'
const RIGHT = 'right'
const MIDDLE = 'middle'The values $button takes.
isLeftClick(): bool
isRightClick(): bool
isMiddleClick(): boolReturn whether the event came from that button.
MouseScrollEvent
final readonly class Phui\Events\Mouse\MouseScrollEvent extends MouseEvent
public string $direction
public int $amountThe scroll direction and the number of steps.
const UP = 'up'
const DOWN = 'down'
const LEFT = 'left'
const RIGHT = 'right'The values $direction takes.
MouseMoveEvent
final readonly class Phui\Events\Mouse\MouseMoveEvent extends MouseEvent
public int $prevX
public int $prevYThe pointer's previous position.
getDelta(): arrayReturns the movement since the previous position.
EmitEvent
final readonly class Phui\Events\EmitEvent extends Event
Carries a value emitted by a component with emit().
public string $name
public Component $emitter
public mixed $dataThe event name, the component that emitted it, and the payload.
getEventType(): stringReturns the emit name rather than the class name, so handlers are registered with the name string rather than EmitEvent::class.
System events
WindowSizeEvent(
public int $width,
public int $height,
)The terminal was resized.
FocusEvent(
public bool $focused,
)The terminal window gained or lost focus.
ColourDepthEvent(
public ColourDepth $depth,
)The terminal reported its colour depth.
SyncSupportEvent(
public bool $supported,
)The terminal reported whether it supports synchronised output.
CursorPositionEvent(
public int $row,
public int $col,
)The terminal reported its cursor position.
StrayOutputEvent(
public string $line,
)Output reached the terminal from outside the renderer.
Enums
MouseTracking
enum Phui\Events\Mouse\MouseTracking
How much mouse activity the terminal reports, set with mouse().
MouseTracking::CLICKReports button presses and releases only.
MouseTracking::DRAGReports presses, releases and movement while a button is held.
MouseTracking::MOTIONReports presses, releases and all movement, whether or not a button is held.
ColourDepth
enum Phui\Events\System\ColourDepth
The colour range the terminal reported, carried by a ColourDepthEvent and mapped to a ColourMode.
ColourDepth::TrueColour24-bit colour.
ColourDepth::Colour256The 256-colour palette.
ColourDepth::Ansi16The 16 base ANSI colours.