wijjit.elements.modal.TextInputDialog

class wijjit.elements.modal.TextInputDialog(prompt, initial_value='', on_submit=None, on_cancel=None, title='Input', classes=None, placeholder='', submit_label='Submit', cancel_label='Cancel', width=50, height=16, border_style='single', input_width=30, id=None)[source]

Text input dialog with prompt, input field, and submit/cancel buttons.

This dialog presents a prompt with a text input field and two buttons (Submit/Cancel). When Submit is clicked, the on_submit callback receives the input value. The dialog automatically closes after a button is clicked.

Parameters:
  • title (str, optional) – Dialog title (default: “Input”)

  • prompt (str) – Prompt message to display above the input field

  • initial_value (str, optional) – Initial value for the text input (default: “”)

  • on_submit (callable, optional) – Callback function called when Submit is clicked. Receives the input value as a string argument: on_submit(value: str)

  • on_cancel (callable, optional) – Callback function called when Cancel button is clicked

  • placeholder (str, optional) – Placeholder text for the input field (default: “”)

  • submit_label (str, optional) – Label for submit button (default: “Submit”)

  • cancel_label (str, optional) – Label for cancel button (default: “Cancel”)

  • width (int, optional) – Dialog width in characters (default: 50)

  • height (int, optional) – Dialog height in lines (default: 16)

  • border_style (str, optional) – Border style: “single”, “double”, or “rounded” (default: “single”)

  • input_width (int, optional) – Width of the text input field (default: 30)

  • classes (str | list[str] | set[str] | None)

  • id (str | None)

Variables:
  • prompt (str) – Dialog prompt message

  • text_input (TextInput) – Text input element

  • submit_button (Button) – Submit button element

  • cancel_button (Button) – Cancel button element

  • close_callback (callable or None) – Callback to close the dialog (set externally by app)

__init__(prompt, initial_value='', on_submit=None, on_cancel=None, title='Input', classes=None, placeholder='', submit_label='Submit', cancel_label='Cancel', width=50, height=16, border_style='single', input_width=30, id=None)[source]
Parameters:
Return type:

None

Methods

__init__(prompt[, initial_value, on_submit, ...])

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.

calculate_content_bounds()

Calculate the bounds available for content inside the frame.

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 modal using cell-based rendering (NEW API).

restore_ephemeral_state(state)

Restore ephemeral state after reconciliation.

set_bounds(bounds)

Set the element's screen bounds.

set_content(content)

Set the modal content text.

toggle_class(class_name)

Toggle a CSS class on this element.

Attributes

captures_tab

Whether this element wants the Tab key instead of focus movement.

parent_frame

Get the parent Frame if this element is inside a scrollable frame.

supports_dynamic_sizing

Whether this element supports dynamic sizing.