Problem
Mouse drag selection and double-click word selection don't work in TextField, despite the selection model being fully implemented internally. The selection model (core/textfield/selection.go), rendering (all 4 theme painters), and keyboard selection (Shift+arrows, Ctrl+A) all work correctly. The gap is in the event dispatch layer.
What works: click to place cursor, Shift+arrows, Ctrl+Shift+arrows (word), Ctrl+A, typing, horizontal scroll.
What doesn't work: mouse drag to select, double-click to select word, Ctrl+C/V to OS clipboard.
Root Cause
Gap 1: MouseDrag never synthesized
app/event_bridge.go:34-38 — OnMouseMove always emits event.MouseMove, even when buttons are pressed. TextField's handleMouseDrag (core/textfield/event.go:49-50) listens for event.MouseDrag which is never dispatched.
Fix: In event_bridge.go, check pressedButtons != 0 during mouse move → emit MouseDrag instead of MouseMove. ~3 lines.
Gap 2: MouseDoubleClick never dispatched
event.MouseDoubleClick type exists (event/mouse.go:33-34). TextField handles it (event.go:52-53, handleDoubleClick selects word via wordBoundsAt()). But no component in the stack generates this event — no double-click timing detector exists in the event bridge, window, or platform layer.
Fix: Add click timing detector in event_bridge.go or app/window.go — two presses within ~400ms at similar position → MouseDoubleClick. Flutter: 300ms, Win32: 500ms. ~30 lines.
Gap 3: Clipboard is internal only
selection.go:9 — clipboard string is an in-memory field. copyToClipboard/pasteFromClipboard (lines 141-151) don't reach the OS clipboard. Ctrl+C/V work within the same widget instance only.
Fix: Wire to platform clipboard — gpucontext.ClipboardProvider interface or direct platform calls (Win32 SetClipboardData/GetClipboardText, macOS NSPasteboard, X11 XSetSelectionOwner, Wayland wl_data_source).
Enterprise References
| Feature |
Flutter |
GTK4 |
Win32 |
| Drag selection |
TextSelectionGestureDetector |
gtk_text_handle_drag |
WM_MOUSEMOVE + MK_LBUTTON |
| Double-click |
kDoubleTapTimeout = 300ms |
GDK_2BUTTON_PRESS |
WM_LBUTTONDBLCLK (500ms default) |
| Triple-click |
kDoubleTapTimeout chain |
GDK_3BUTTON_PRESS |
Manual detection |
| OS clipboard |
Clipboard.getData |
gtk_clipboard_get |
GetClipboardData |
Implementation Priority
- MouseDrag synthesis (~3 LOC) — unblocks drag selection immediately
- Double-click detection (~30 LOC) — word selection
- OS clipboard (~100 LOC across platforms) — copy/paste interop
- Triple-click line select (~10 LOC) — nice-to-have
Problem
Mouse drag selection and double-click word selection don't work in TextField, despite the selection model being fully implemented internally. The selection model (
core/textfield/selection.go), rendering (all 4 theme painters), and keyboard selection (Shift+arrows, Ctrl+A) all work correctly. The gap is in the event dispatch layer.What works: click to place cursor, Shift+arrows, Ctrl+Shift+arrows (word), Ctrl+A, typing, horizontal scroll.
What doesn't work: mouse drag to select, double-click to select word, Ctrl+C/V to OS clipboard.
Root Cause
Gap 1: MouseDrag never synthesized
app/event_bridge.go:34-38—OnMouseMovealways emitsevent.MouseMove, even when buttons are pressed. TextField'shandleMouseDrag(core/textfield/event.go:49-50) listens forevent.MouseDragwhich is never dispatched.Fix: In
event_bridge.go, checkpressedButtons != 0during mouse move → emitMouseDraginstead ofMouseMove. ~3 lines.Gap 2: MouseDoubleClick never dispatched
event.MouseDoubleClicktype exists (event/mouse.go:33-34). TextField handles it (event.go:52-53,handleDoubleClickselects word viawordBoundsAt()). But no component in the stack generates this event — no double-click timing detector exists in the event bridge, window, or platform layer.Fix: Add click timing detector in
event_bridge.goorapp/window.go— two presses within ~400ms at similar position →MouseDoubleClick. Flutter: 300ms, Win32: 500ms. ~30 lines.Gap 3: Clipboard is internal only
selection.go:9—clipboard stringis an in-memory field.copyToClipboard/pasteFromClipboard(lines 141-151) don't reach the OS clipboard. Ctrl+C/V work within the same widget instance only.Fix: Wire to platform clipboard —
gpucontext.ClipboardProviderinterface or direct platform calls (Win32SetClipboardData/GetClipboardText, macOSNSPasteboard, X11XSetSelectionOwner, Waylandwl_data_source).Enterprise References
TextSelectionGestureDetectorgtk_text_handle_dragWM_MOUSEMOVE + MK_LBUTTONkDoubleTapTimeout = 300msGDK_2BUTTON_PRESSWM_LBUTTONDBLCLK(500ms default)kDoubleTapTimeoutchainGDK_3BUTTON_PRESSClipboard.getDatagtk_clipboard_getGetClipboardDataImplementation Priority