Skip to content

Add caret, text selection and copy/cut/paste to the chat input box#4976

Open
TheCrazy17 wants to merge 3 commits into
multitheftauto:masterfrom
TheCrazy17:feature/chat-caret-selection-copypaste
Open

Add caret, text selection and copy/cut/paste to the chat input box#4976
TheCrazy17 wants to merge 3 commits into
multitheftauto:masterfrom
TheCrazy17:feature/chat-caret-selection-copypaste

Conversation

@TheCrazy17

@TheCrazy17 TheCrazy17 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds, on top of the existing custom-drawn chat input (no migration to a CEGUI editbox):

  • A visible, blinking, movable caret
  • Left/Right/Home/End navigation, with Ctrl for word-skipping
  • Delete (removes the character ahead of the caret)
  • Shift (+Ctrl) + Left/Right/Home/End to extend a selection, with visual highlight
  • Ctrl+A to select all
  • Ctrl+C/X/V to copy/cut/paste against the system clipboard
  • Click-and-drag with the mouse to select text in the input line
Chat.test.mp4

Out of scope (left for a follow-up): scriptable client-side auto-completion, and selecting/copying text from already-sent chat history lines with the mouse.

Motivation

The chat input box was hand-rolled text editing with no concept of a cursor: Backspace only removed the last character, and there was no way to navigate within the text, select a range, or use the system clipboard, unlike the debug console, which already gets all of this for free from CGUIEdit.

Implement one of the ideas of (but no closes) #755 (caret, selection and copy/paste; auto-completion not included).

Test plan

Manually tested in-game:

  • Typing and caret movement (arrows, Ctrl+arrows, Home/End)
  • Selection via keyboard (Shift+arrows, Ctrl+A) and mouse drag, with the highlight rendering correctly
  • Ctrl+C/X/V against the system clipboard (including pasting external text)
  • Multi-line wrapped input (long messages)
  • Tested with diferents chats layouts/scales/fonts

To verify: open the chat, type a message, move the caret around with arrows/Ctrl+arrows, select text with Shift+arrows or by dragging the mouse, and try Ctrl+A/C/X/V.

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

The chat input never had a real cursor: backspace only worked at the end
of the line, and there was no way to move around, select text, or use
copy/paste. The debug console gets all of this for free from CGUIEdit,
but the chat input draws its own text by hand, so none of it applied
there.

Adds a blinking caret, left/right/home/end navigation (ctrl to skip
words), delete, shift-extendable selection with a highlight, ctrl+a,
ctrl+c/x/v against the system clipboard, and mouse drag selection - all
on top of the existing custom-drawn input instead of switching it over
to a CEGUI editbox.

Partially addresses multitheftauto#755 (caret/selection/copy-paste only, no
scriptable auto-completion)
It was advancing by a fixed step every draw call, so it blinked faster
at higher framerates instead of on a real clock. Switched it to
GetSecondCount(), which the rest of this file already uses for timing.
Also named the selection highlight color and caret width instead of
leaving them as bare numbers, and dropped an unused helper.
@Dryxio

Dryxio commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

very cool, this was always a real lack

A few hand-aligned comments and column widths didn't match what
clang-format recalculates after the new code, which is what the CI
formatting check was catching.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants