Is the full behaviour of textboxes documented anywhere?

PC games often have to build their own UI widgets (buttons, input textboxes, etc). Fortunately it’s relatively trivial to write one’s own textbox from scratch given only a 2D drawing API and user-input event messages:

  • State:

    • Current text buffer
    • Textbox dimensions
    • Current caret location and current text selection range
    • Simple options, e.g. is read-only, etc
  • Render:

    • Draw rectangle (maybe with an inset border look)
    • Draw line of text from the internal buffer within the dimensions
    • Draw caret and/or text selection
  • User input:

    • On key-press:
      • If character key was pressed, insert that character into the buffer at the caret’s location (often just appending to the end)
      • If control key was pressed (e.g. backspace) then handle each control key appropriately
      • If arrow keys, then move the caret accordingly, including up/down for multi-line text-boxes
    • On key-down
      • If key held down for > 3 seconds then repeat key-press until key-up

So far, so simple.

But I noticed that many games and even business software using custom widget toolkits (thank you, WPF…) don’t match the full set of functionality provided by the Microsoft Windows’ User32 textbox (formally, the Edit Control).

Examples of this functionality missing from other implementations includes multiple keystroke (key-chord?) commands and various kinds of system integration for example:

  • Ctrl + Arrow-keys to move the caret to the next word-boundary
  • Shift + Arrow-keys for selection
  • Ctrl + Shift + Arrow-keys for selection to the next word-boundary
  • Built-in spell-checker with red-squiggle underlines
  • Right-click context menu
  • Ctrl+A to select all
  • Automatically opening the system’s on-screen keyboard when the control gains focus
  • “Tab” focus highlighting

But I noticed that these keystrokes and shortcuts are also accepted by other standard textboxes present in other platforms, sparing minor differences (e.g. on macOS it’s Alt+Arrow-keys to move between word-boundaries).

But it’s not just keystrokes, also consider things like rendering Unicode correctly as Unicode includes rules on text layout (e.g. Zalgo text via Combining Marks) – granted this is more to do with the text rendering library being used than the textbox itself.

So I was wondering if there exists something like an “ISO standard for input textboxes” or something similar that sets out all standard behaviour of a textbox so that developers of a new platform know exactly the functionality they need to implement to build something like that on other systems – without needing to go through proprietary, platform-specific documentation that may hide undocumented features. I note that the documentation for Win32’s Edit Control doesn’t go into details about the user-facing functionality (which is exactly what I’m talking about) because that’s something you’d read in the User Manual, not the programming reference – especially because the functionality of the Edit Control is improved and extended in future versions of Windows without the original hosting application’s developers needing to do anything.