The direct text editing mode introduced for KBM users had several
issues with the TextInput control's caret (blinking cursor) and text
manipulation:
1. Caret visible when not editing:
When navigating to the world name field with keyboard/mouse, Flash's
Iggy focus system would show the blinking caret even though the field
wasn't active for editing yet (Enter not pressed). This was misleading
since typing had no effect in that state.
Fix: access the FJ_TextInput's internal m_mcCaret MovieClip and
force its visibility based on editing state. This is enforced every
tick because setLabel() and Flash focus transitions continuously
reset the caret state.
2. No cursor movement during editing:
The direct edit implementation treated the text as a simple buffer
with push_back/pop_back — there was no concept of cursor position.
Backspace only deleted from the end, and arrow keys did nothing.
Fix: track cursor position (m_iCursorPos) in C++ and use wstring
insert/erase at that position. Arrow keys (Left/Right), Home, End,
and Delete now work as expected. The visual caret position is synced
to Flash via the FJ_TextInput's SetCaretIndex method.
3. setLabel() resetting caret position:
Every call to setLabel() (when text changes) caused Flash to reset
the caret to the end of the string, making the cursor jump visually
even though the C++ position was correct.
Fix: enforce caret position via setCaretIndex every tick during
editing, so any Flash-side resets are immediately corrected.
New UIControl_TextInput API:
- setCaretVisible(bool): toggles m_mcCaret.visible in Flash
- setCaretIndex(int): calls FJ_TextInput.SetCaretIndex in Flash