Skip to content

Refactor InputSystem#3173

Draft
halx99 wants to merge 10 commits into
devfrom
input-field
Draft

Refactor InputSystem#3173
halx99 wants to merge 10 commits into
devfrom
input-field

Conversation

@halx99

@halx99 halx99 commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Describe your changes

  • Replace legacy TextFieldTTF usage/removal and shift text input flows toward ui::InputField/IME-based behavior.
  • Add unified Label::create(text, fontName, fontSize) API with automatic font-type detection (BMFont/TTF/system font).
  • Add Label::setFontInfo(fontName, fontSize) to centralize runtime font switching.
  • Clean up Label internals by removing cached _lengthOfString state and deriving count from UTF-32 text (getCharCount()), reducing stale-length risks.
  • Introduce/rename clearer label query APIs (getLineCount(), getCharCount()) while keeping backward-compatible deprecated wrappers.
  • Harden UTF-8 handling paths in label/text operations (avoid accepting invalid UTF-8 silently).
  • Update desktop/input related plumbing and scene/UI compatibility touchpoints associated with the migration.
  • Apply broad cleanup/modernization in tests and headers (e.g., #pragma once, include path corrections, minor code hygiene).
  • Integrate iOS System Copy/Paste Menu for InputField Editing

Issue ticket number and link

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

Axmol 3.x ------------------------------------------------------------

For each 3.x PR

  • Check the '#include "axmol.h"' and replace it with the needed headers.

@halx99 halx99 added this to the 3.0.0 milestone May 19, 2026
@halx99 halx99 linked an issue May 19, 2026 that may be closed by this pull request
@halx99 halx99 changed the title Input field Implement #3168 May 19, 2026
@halx99

halx99 commented May 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 211c215351

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread axmol/ui/UIWidget.cpp Outdated
Comment thread extensions/scripting/lua-bindings/auto/axlua_ui_auto.cpp Outdated
@halx99

halx99 commented May 20, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

@halx99

halx99 commented May 20, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2aff1905b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/sceneio/src/sceneio/WidgetReader/WidgetReader.cpp Outdated
Comment thread axmol/ui/UIButton.cpp Outdated
Comment thread axmol/ui/UIWidget.cpp Outdated
Comment thread axmol/ui/InputField.cpp Outdated
@halx99

halx99 commented May 20, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

@halx99

halx99 commented May 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa51937953

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread axmol/ui/InputField.cpp Outdated
Comment thread axmol/ui/InputField.cpp Outdated
@halx99

halx99 commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

@halx99

halx99 commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@halx99

halx99 commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca81b1bcfa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread axmol/ui/InputField.cpp Outdated
Comment thread axmol/base/text_utils.cpp Outdated
@halx99

halx99 commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f219568f06

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread axmol/platform/desktop/RenderViewImpl.cpp Outdated
Comment thread axmol/platform/pc/RenderView-pc.cpp
@halx99

halx99 commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@halx99 halx99 added the enhancement New feature or request label May 22, 2026
@halx99

halx99 commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author

@codex About this PR, do you have any suggestion to improve ui::InputField implementation?

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00d565bf4e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/sceneio/src/sceneio/ActionTimeline/CSLoader.cpp Outdated
Comment thread axmol/base/IMEDispatcher.cpp Outdated
@halx99

halx99 commented May 23, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

@halx99

halx99 commented May 23, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac07dc212c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread axmol/platform/desktop/Device-desktop.cpp Outdated
Comment thread axmol/platform/desktop/Device-desktop.cpp Outdated
Comment thread axmol/platform/desktop/Device-desktop.cpp Outdated
@halx99

halx99 commented May 23, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

@halx99

halx99 commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@halx99

halx99 commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

@codex provide merge title and change detail list about this PR via https://patch-diff.githubusercontent.com/raw/axmolengine/axmol/pull/3173.diff

@halx99

halx99 commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

@chatgpt-codex-connector

Copy link
Copy Markdown

Proposed merge metadata based on the PR diff and review context:

Merge title

Refactor legacy text input stack to ui::InputField and unify font handling APIs

Change detail list (for squash/merge message)

  • Replace legacy TextFieldTTF usage/removal and shift text input flows toward ui::InputField/IME-based behavior.
  • Add unified Label::create(text, fontName, fontSize) API with automatic font-type detection (BMFont/TTF/system font).
  • Add Label::setFontInfo(fontName, fontSize) to centralize runtime font switching.
  • Clean up Label internals by removing cached _lengthOfString state and deriving count from UTF-32 text (getCharCount()), reducing stale-length risks.
  • Introduce/rename clearer label query APIs (getLineCount(), getCharCount()) while keeping backward-compatible deprecated wrappers.
  • Harden UTF-8 handling paths in label/text operations (avoid accepting invalid UTF-8 silently).
  • Update desktop/input related plumbing and scene/UI compatibility touchpoints associated with the migration.
  • Apply broad cleanup/modernization in tests and headers (e.g., #pragma once, include path corrections, minor code hygiene).

If you want, I can also draft a “merge title + detailed changelog” in Conventional Commits style (e.g., refactor(ui): ...) for direct paste into GitHub.

Source used:

View task →

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the UI and text input systems, replacing legacy TextField components with a new InputField widget and introducing a cross-platform clipboard API. It also updates the layout system by replacing ignoreContentAdaptWithSize with setAutoSize and renames various UI headers for consistency. Feedback highlights critical logic inversions in the setAutoSize implementation for several widgets (Button, ImageView, Slider, and LoadingBar) when Scale9 is enabled, which hinders manual sizing. Further improvements are suggested for Android clipboard robustness, touch position tracking in InputField, and optimizing the O(N^2) performance of the text layout measurement logic.

Comment thread axmol/ui/Button.cpp Outdated
Comment thread axmol/ui/ImageView.cpp Outdated
Comment thread axmol/ui/Slider.cpp Outdated
Comment thread axmol/ui/LoadingBar.cpp Outdated
Comment thread axmol/platform/android/java/src/dev/axmol/lib/AxmolEngine.java
Comment thread axmol/ui/InputField.cpp Outdated
Comment thread axmol/ui/InputField.cpp Outdated
@gemini-code-assist

Copy link
Copy Markdown

Hello halx99, thank you for reaching out. Regarding your question about the ui::InputField implementation, it is designed to be a more modern, IME-friendly replacement for the legacy TextFieldTTF.

Key improvements include:

  1. IME Integration: It utilizes the new InputDelegate and InputDispatcher architecture, which provides better support for platform-native IME features (like pre-edit text updates) compared to the legacy IMEDelegate.
  2. Cursor & Selection: It includes built-in cursor management and selection handling, which were significant pain points in the legacy implementation.
  3. Font Flexibility: The unified Label::create(text, fontName, fontSize) API allows for easier font handling across different types (BMFont, TTF, System).
  4. Performance: By deriving character counts from UTF-32 text (getCharCount()) and removing stale state like _lengthOfString, it reduces synchronization risks and improves performance.

If you are looking to migrate from TextFieldTTF or TextField, I recommend focusing on the InputField factory methods and the event-based listener system (addEventListener) to handle input changes, as this is the intended pattern for the new stack. Let me know if you have specific architectural questions or need help with a particular use case!

@halx99

halx99 commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

@gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request performs a major refactoring of the UI and input systems, replacing the deprecated TextFieldTTF and TextFieldEx widgets with a new InputField component that supports multiline text, cursors, and selections. The refactor includes a widespread renaming of UI classes and core methods (e.g., setAutoSize, getRenderNode) to improve API consistency, renames the IME system to a more general Input system, and introduces a cross-platform clipboard API. Review feedback identifies a high-severity risk of null pointer exceptions in the Android clipboard implementation and suggests adopting safer string access patterns in the InputField logic.

Comment thread axmol/platform/android/java/src/dev/axmol/lib/AxmolEngine.java
Comment thread axmol/ui/InputField.cpp Outdated
@halx99

halx99 commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

1 similar comment
@halx99

halx99 commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

@halx99

halx99 commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request overhauls the text input and UI widget systems by introducing a modern InputField component to replace the deprecated TextFieldTTF and TextFieldEx. The new InputField supports multiline text, cursor control, selection, and native clipboard integration. Additionally, the Widget base class and its derivatives have been refactored to use a standardized setAutoSize and initRenderNode API, and the IME system has been renamed to InputDelegate. Reviewer feedback highlights significant efficiency and correctness concerns regarding character-by-character text measurement and the lack of word-level wrapping in multiline mode. Other actionable suggestions include syncing measurement labels with rendering effects, adjusting long-press trigger timing on mobile platforms, and correcting a typo in Label.cpp.

Comment thread axmol/ui/InputField.cpp
Comment thread axmol/2d/Label.cpp
Comment thread axmol/ui/InputField.cpp
Comment thread axmol/ui/InputField.cpp
Comment thread axmol/ui/InputField.cpp
Comment thread axmol/ui/InputField.cpp
@halx99 halx99 marked this pull request as draft May 25, 2026 23:45
@halx99 halx99 changed the title Refactor legacy text input stack to ui::InputField and unify font handling APIs Refactor InputSystem Jun 2, 2026
@codacy-production

codacy-production Bot commented Jun 4, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 high

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
ErrorProne 1 high

View in Codacy

🟢 Metrics 4329 complexity · 98 duplication

Metric Results
Complexity 4329
Duplication 98

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@halx99 halx99 force-pushed the input-field branch 3 times, most recently from d163ad8 to 4e27179 Compare June 7, 2026 09:05
@halx99

halx99 commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking changes enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImGui text and numeric input widgets do not accept keyboard input on macOS after updating to v1.92.7 Refactor InputSystem

2 participants