Skip to content

Fixes #5469 - Add editable text mode to NumericUpDown#5587

Merged
tig merged 3 commits into
developfrom
copilot/enhance-numericupdown-editable-text-mode
Jul 9, 2026
Merged

Fixes #5469 - Add editable text mode to NumericUpDown#5587
tig merged 3 commits into
developfrom
copilot/enhance-numericupdown-editable-text-mode

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #5469

Proposed Changes/Todos

NumericUpDown<T> now supports an optional editable mode that preserves the existing compact spinner behavior by default. When enabled, the value region becomes a text editor backed by TextField, allowing direct entry while keeping increment/decrement semantics aligned with the last valid parsed value.

  • Added optional edit mode

    • Added CanEdit to NumericUpDown<T> and kept the default false so current compact rendering stays unchanged.
    • Editable mode uses a TextField-backed value host and reserves an extra column so the cursor remains visible at the end of the text.
  • Preserved numeric semantics while editing

    • Valid text updates Value and re-formats the display through Format.
    • Invalid text remains visible for correction without changing Value.
    • Up/down commands operate from the last valid value and resync the editor text to the formatted display.
  • Added focused coverage

    • Added unit tests for valid input, invalid input, and resync behavior after increment/decrement.

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

Copilot AI assigned Copilot and tig Jul 7, 2026
Copilot AI linked an issue Jul 7, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Enhance NumericUpDown with optional editable text mode Add editable text mode to NumericUpDown Jul 7, 2026
Copilot finished work on behalf of tig July 7, 2026 14:46
Copilot AI requested a review from tig July 7, 2026 14:46
@tig tig marked this pull request as ready for review July 7, 2026 22:35
Two defects in the new CanEdit mode:

- UpdateNumberView appended the value view after the up button, so the
  SubViews order became [down, up, editor]. Because the focus chain is
  derived from SubViews order, Tab navigation visited the up button before
  the editor, contradicting the visual layout. Insert the value view between
  the buttons via MoveSubViewTowardsStart.

- Every parsed keystroke set Value, whose setter reformatted the editor text,
  making fractional entry impossible (typing "3." for a {0:0.00} field became
  "3.00" immediately). Guard SetText with _editingFromUser so user typing
  updates Value without overwriting the in-progress text; the editor still
  resyncs on Up/Down and external Value changes.

Tests updated/added accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tig tig requested review from BDisp and harder July 8, 2026 15:57
@tig tig changed the title Add editable text mode to NumericUpDown Fixes #5469 - Add editable text mode to NumericUpDown Jul 8, 2026
@tig tig merged commit 8975fec into develop Jul 9, 2026
14 checks passed
@tig tig deleted the copilot/enhance-numericupdown-editable-text-mode branch July 9, 2026 02:54
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.

Enhance NumericUpDown with optional editable text mode

3 participants