Textbox – Is the overall behavior of textboxes documented somewhere?

PC games often need to create their own UI widgets (buttons, input text fields, etc.). Fortunately, creating a custom text box from scratch when entering only a 2D drawing API and event messages from users is relatively trivial:

  • State:

    • Current text buffer
    • Text Box dimensions
    • Current caret location and current text selection area
    • Simple options, eg. is write protected etc
  • Do:

    • Draw rectangle (possibly with inserted edge optics)
    • Draw a line of text from the internal buffer within the dimensions
    • Draw an insertion point and / or a text selection
  • User input:

    • When pressed:
      • If the character key was pressed, insert this character into the buffer at the insertion mark position (often only at the end).
      • If the control key has been pressed (eg Backspace), then treat each control key accordingly
      • If you use the arrow keys, move the insertion point accordingly
    • When shutting down
      • If the button is pressed for more than 3 seconds, repeat the button until the button is pressed

So easy.

However, I've found that many games and even enterprise software that uses custom widget toolkits (thanks, WPF …) do not provide the full functionality of Microsoft Windows's User32 text box (formally the Edit Control).

Examples of this functionality lacking in other implementations include multiple keystrokes and various types of system integration, for example:

  • Ctrl + arrow keys to move the insertion point to the next word boundary
  • Shift + arrow keys to choose
  • Ctrl + Shift + Arrow keys to select the next word boundary
  • Built-in spell checker with red underlines
  • Click with the right mouse button on the context menu
  • Ctrl + A to select all
  • Automatically open the on-screen keyboard of the system when the control receives focus
  • Highlighting the focus marker "Tab"

However, I've found that these keystrokes and keyboard shortcuts are also accepted by other standard text fields that exist on other platforms, which avoids minor differences (for example, macOS uses Alt + arrow keys to move between word boundaries).

It's not just about keystrokes, it's about rendering Unicode correctly because Unicode includes rules for text layout (for example, combining Zalgo text with markers). However, this depends more on the text rendering library used than on the textbox itself.

So I was wondering if there is something like an "ISO standard for input text fields" or something similar that sets the default behavior of a text box so that developers of a new platform know exactly the functionality they need to implement to build something like that other systems – without having to go through proprietary, platform-specific documentation that can hide undocumented features. I note that the Win32 Edit Control documentation does not contain any details about the user-oriented functions (which is exactly what I am talking about) because you read this in the User's Guide, not in the Programmer's Reference – especially because the functionality of the Edit Controls in future versions of Windows will be enhanced and enhanced without the developers of the original hosting application having to do anything.