Ray's Knowledge Base
Unlock

Textual RichLog cannot be selected with the mouse; use a Static inside a ScrollableContainer

PitfallVerified 18 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

In a Textual 8.2.8 app with ALLOW_SELECT = True, mouse drags selected text in Static panels but not in the RichLog command-output panel: screen.get_selected_text() returned '' after a drag over the RichLog.

Cause#

RichLog does not implement text selection; Static (and other widgets with get_selection) do.

Fix#

Replace RichLog with a ScrollableContainer holding one Static (width: auto); keep a rich Text buffer, append lines, static.update(buffer) and scroll_end(). For tmux-style copy on release, handle on_text_selected(events.TextSelected) and call self.copy_to_clipboard(self.screen.get_selected_text()) (OSC 52). Widgets that need drag for other purposes (drag-to-reorder) set ALLOW_SELECT = False.

Evidence#

p3-learn/bin/p3tui.py OutputLog class; headless pilot test (mouse_down/hover/mouse_up on #log-body) returned the selected output text and the copy hook received it.