[PR #452] [MERGED] World screens' text fields: move the cursor, select, click and drag #2576

Closed
opened 2026-11-02 15:57:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/452
Author: @ludovic111
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ludovic111

Base: main ← Head: fix/classic-text-fields


📝 Commits (1)

  • 6085076 Classic world fields edit at a cursor: arrows, Home/End, Delete, clicks and drags

📊 Changes

6 files changed (+365 additions, -106 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+21 -1)
📝 crates/horizon-client/src/game/clipboard.rs (+9 -5)
📝 crates/horizon-client/src/title.rs (+123 -82)
📝 crates/horizon-client/src/title/create_world.rs (+18 -16)
📝 crates/horizon-client/src/title/tests.rs (+25 -0)
📝 crates/horizon-client/src/ui.rs (+169 -2)

📄 Description

Fixes #383

What vanilla does (EditBox)

  • keyPressed: Left/Right move the cursor, by word with Ctrl, and Shift extends the selection. Home/End, Backspace/Delete (by word with Ctrl) and Ctrl+A/C/V/X work on the selection.
  • onClick puts the cursor under the pointer (findClickedPositionInText), and Shift extends the selection. A double click (MouseHandler: a second click on the screen within 250 ms) selects the word (selectWord). onDrag moves the cursor with the selection anchored.

Horizon's classic world screens kept a plain String per field and only appended to it or popped from it: the world list's search, Edit World's name, and Create New World's name and seed. Arrows and clicks did nothing and there was no selection beyond Select All.

Changes

  • ui.rs:
    • EditBox::position_at, click (Shift and double click) and drag_to;
    • ui::Caret, which keeps the focused field's EditBox (cursor, selection, scroll) beside the screen's String and writes edits back. A field whose value changes elsewhere starts again with its cursor at the end.
  • title.rs, title/create_world.rs: those four fields draw and edit through the caret (field_key, field_shortcut, press_field, drag_field). type_text / backspace now work at the cursor. The old hand-drawn text_field is gone.
  • game.rs, game/clipboard.rs:
    • arrows, Home/End, Delete and Backspace go to the focused field;
    • left presses and drags place the cursor;
    • Ctrl/Cmd+A/C/V/X act on the field's selection.
  • Not included:
    • The server screens' boxes (Add Server, Direct Connection, invite code) still append. #423 is rewriting those boxes; they move onto ui::Caret once it's merged.
    • The creative search box.

How it was verified

  • Unit tests:
    • edit_box_clicks_place_the_cursor_and_select: click placement, Shift+click selection, double-click word selection, drag;
    • world_fields_edit_at_their_cursor: arrows, insert mid-text, Shift+Home then type replaces the selection, Ctrl+Left, Backspace.
  • In game on the Mac mini (offscreen; horizon-ctl can't send title-screen keys, so those are covered by the tests):
    • typed "hello world" in the world search, clicked after "hell" and typed X: hellXo world, with the insert bar at the cursor;
    • dragged across "world": selected with vanilla's highlight;
    • two clicks within 250 ms select the word, as vanilla's double click does.

Self-check (fmt, clippy, client tests, parity) for the whole batch: see the last comment.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/452 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/classic-text-fields` --- ### 📝 Commits (1) - [`6085076`](https://github.com/horizon-rust/horizon/commit/608507699c9553809d15d4d6dac5f970ecc208f0) Classic world fields edit at a cursor: arrows, Home/End, Delete, clicks and drags ### 📊 Changes **6 files changed** (+365 additions, -106 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+21 -1) 📝 `crates/horizon-client/src/game/clipboard.rs` (+9 -5) 📝 `crates/horizon-client/src/title.rs` (+123 -82) 📝 `crates/horizon-client/src/title/create_world.rs` (+18 -16) 📝 `crates/horizon-client/src/title/tests.rs` (+25 -0) 📝 `crates/horizon-client/src/ui.rs` (+169 -2) </details> ### 📄 Description Fixes #383 **What vanilla does** (`EditBox`) - `keyPressed`: Left/Right move the cursor, by word with Ctrl, and Shift extends the selection. Home/End, Backspace/Delete (by word with Ctrl) and Ctrl+A/C/V/X work on the selection. - `onClick` puts the cursor under the pointer (`findClickedPositionInText`), and Shift extends the selection. A double click (`MouseHandler`: a second click on the screen within 250 ms) selects the word (`selectWord`). `onDrag` moves the cursor with the selection anchored. Horizon's classic world screens kept a plain `String` per field and only appended to it or popped from it: the world list's search, Edit World's name, and Create New World's name and seed. Arrows and clicks did nothing and there was no selection beyond Select All. **Changes** - `ui.rs`: - `EditBox::position_at`, `click` (Shift and double click) and `drag_to`; - `ui::Caret`, which keeps the focused field's `EditBox` (cursor, selection, scroll) beside the screen's `String` and writes edits back. A field whose value changes elsewhere starts again with its cursor at the end. - `title.rs`, `title/create_world.rs`: those four fields draw and edit through the caret (`field_key`, `field_shortcut`, `press_field`, `drag_field`). `type_text` / `backspace` now work at the cursor. The old hand-drawn `text_field` is gone. - `game.rs`, `game/clipboard.rs`: - arrows, Home/End, Delete and Backspace go to the focused field; - left presses and drags place the cursor; - Ctrl/Cmd+A/C/V/X act on the field's selection. - Not included: - The server screens' boxes (Add Server, Direct Connection, invite code) still append. #423 is rewriting those boxes; they move onto `ui::Caret` once it's merged. - The creative search box. **How it was verified** - Unit tests: - `edit_box_clicks_place_the_cursor_and_select`: click placement, Shift+click selection, double-click word selection, drag; - `world_fields_edit_at_their_cursor`: arrows, insert mid-text, Shift+Home then type replaces the selection, Ctrl+Left, Backspace. - In game on the Mac mini (offscreen; horizon-ctl can't send title-screen keys, so those are covered by the tests): - typed "hello world" in the world search, clicked after "hell" and typed X: `hellXo world`, with the insert bar at the cursor; - dragged across "world": selected with vanilla's highlight; - two clicks within 250 ms select the word, as vanilla's double click does. Self-check (fmt, clippy, client tests, parity) for the whole batch: see the last comment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:57:20 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2576
No description provided.