wijjit.elements.menu.ContextMenu

class wijjit.elements.menu.ContextMenu(id=None, classes=None, items=None, target_element_id=None, width=30, border_style=BorderStyle.SINGLE)[source]

Context menu element.

A context menu appears at the mouse cursor position when triggered by a right-click on a target element. It auto-positions to stay on screen.

Parameters:
  • id (str, optional) – Unique identifier

  • items (list of MenuItem, optional) – Menu items to display

  • target_element_id (str or None, optional) – ID of the element this context menu is attached to

  • width (int, optional) – Menu width (default: 30)

  • border_style (BorderStyle or str, optional) – Border style (default: BorderStyle.SINGLE)

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

Variables:
  • target_element_id (str or None) – ID of the target element

  • mouse_position (tuple of (int, int) or None) – Mouse cursor position (x, y) where menu was triggered

__init__(id=None, classes=None, items=None, target_element_id=None, width=30, border_style=BorderStyle.SINGLE)[source]
Parameters:
Return type:

None

Methods

__init__([id, classes, items, ...])

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 for 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 keyboard input for menu navigation.

handle_mouse(event)

Handle mouse input for menu interaction.

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

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_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.