1

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.

2
  • 1
    rules are for fools
    – Confused
    Nov 24, 2018 at 23:12
  • Don't forget, Page Up / Down, Ctrl + End / Home. Which is also common. Dec 14, 2020 at 10:49

1 Answer 1

1

As far as I know, No, there is no standard.

While the basic concept you are suggesting sounds reasonable/logical, in reality you are mixing together a lot of different things, which give the various systems (browsers, operating systems, physical devices) their "personality".

  • Keyboard functions, while somewhat standardized in many operating systems, can vary based on keyboard type, country/region and other factors.
  • Built-in spell checker with red squiggles has become a de-facto standard, but is a relatively new invention. (I did my own spell-checking in text fields ~ 25 or more years ago, as part of my own text-based text boxes (no GUI) - red squiggles were just a dream at the time)
  • Multi-keystroke commands are problematic for certain types of disabilities, industrial environments (try using a keyboard that way with heavy gloves on) and other special situations.
  • New devices often function quite differently from not-so-old ones - e.g., an Android or iPhone does things with touchscreens that previously had to be done with keystrokes, and the equivalent keystrokes are generally not even an option on those devices.

The end result is that the concept of a text box is quite standard (e.g., HTML has which provides certain required functionality and recommendations for some visual aspects), the implementation details are left to the developer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.