wijjit.elements.base.OverlayElement
- class wijjit.elements.base.OverlayElement(id=None, classes=None, tab_index=None, width=None, height=None, centered=True)[source]
Base class for overlay content elements.
This class provides a foundation for elements displayed in overlays (modals, dropdowns, tooltips). It extends Container to support child elements and adds overlay-specific properties.
- Parameters:
id (
str, optional) – Unique identifierclasses (
strorlistofstrorsetofstr, optional) – CSS class names for stylingtab_index (
int, optional) – Tab order for focus navigationwidth (
int, optional) – Desired width in charactersheight (
int, optional) – Desired height in linescentered (
bool, optional) – Whether to center the overlay (default: True)
- Variables:
Methods
__init__([id, classes, tab_index, width, ...])add_child(element)Add a child element.
add_class(class_name)Add a CSS class to this element.
apply_props(props)Apply props from a VNode, skipping ephemeral props.
get_ephemeral_state()Get ephemeral state that should survive reconciliation.
get_focusable_children()Get all focusable child elements.
get_hardware_cursor_position()Absolute screen cell where the hardware terminal cursor should park.
get_height_for_width(width)Return the height this element needs when laid out at
width.get_intrinsic_size()Get the intrinsic (preferred) size of the element.
handle_key(key)Handle key press by routing to focused child.
handle_mouse(event)Handle mouse event by routing to child at mouse position.
has_class(class_name)Check if element has a CSS class.
on_blur()Called when element loses focus.
on_focus()Called when element gains focus.
on_hover_enter()Called when mouse enters element.
on_hover_exit()Called when mouse exits element.
on_mount()Called when element is first added to the element tree.
on_unmount()Called when element is removed from the element tree.
on_update(changed_props)Called when element props are updated during reconciliation.
remove_child(element)Remove a child element.
remove_class(class_name)Remove a CSS class from this element.
render_signature()Hashable/comparable capture of everything
render_to()reads.render_to(ctx)Render the container using cell-based rendering.
restore_ephemeral_state(state)Restore ephemeral state after reconciliation.
set_bounds(bounds)Set the element's screen bounds.
toggle_class(class_name)Toggle a CSS class on this element.
Attributes
captures_tabWhether this element wants the Tab key instead of focus movement.
parent_frameGet the parent Frame if this element is inside a scrollable frame.
supports_dynamic_sizingWhether this element supports dynamic sizing.
- handle_key(key)[source]
Handle key press by routing to focused child.
- Parameters:
key (
Key) – The key that was pressed- Returns:
True if the key was handled, False otherwise
- Return type:
- async handle_mouse(event)[source]
Handle mouse event by routing to child at mouse position.
- Parameters:
event (
MouseEvent) – The mouse event that occurred- Returns:
True if the event was handled by a child, False otherwise
- Return type:
Notes
This method checks each child to see if the mouse event occurred within its bounds. If so, it dispatches the event to that child. Children are checked in reverse order so that later children (rendered on top) get priority.