Windows 8 introduced substantially better touch facilities than those available in Windows 7.  One cool thing is the new touch on-screen keyboard, which is enabled if you have a touch screen. To see it, swipe in from the right side, touch the cog icon for settings, touch the Keyboard, and then touch “Touch keyboard and handwriting panel”. This displays the touch keyboard across the bottom of the screen. As is typical with on-screen keyboards, this one shows upper-case letters when the shift key is pressed, alternate keys when an alt key is pressed, and selecting a different language keyboard displays the appropriate keys for that language. A new feature is that if you keep pressing a key, it may display a set of alternative keys around the original. For example if you press the a key, you’ll see a whole group of accented a keys, which you can then move to and insert. Similarly if you press the = key, you see a display of ≡ ¬ ≠ ≈ ≉, which you can insert. Imagine, in principle you could design a math keyboard with all the Unicode math characters this way! This blog post doesn’t pursue this exciting possibility, but instead describes how a programmer can take advantage of some touch functionality added to RichEdit 8 in Windows 8.

Touch facilities such as zooming with pinch and expand (reverse pinch) are typically handled by the client using transforms. RichEdit itself has been generalized to handle the selection and grippers on Windows 8 touch devices. These features are available to clients who want to offer touch capabilities with standard Windows apps using msftedit.dll. For Windows RT apps based on the XAML RichEditBox and TextBox controls, which also use msftedit.dll, touch facilities are handled by the XAML infrastructure.

Specifically, sending an EM_SETEDITSTYLEEX message with the SES_EX_MULTITOUCH extended edit style enables or disables the touch features. They are disabled by default, for which touch input is simulated by mouse messages. The new messages EM_SETTOUCHOPTIONS and EM_GETTOUCHOPTIONS can be used to control whether the selection handles (grippers) are displayed.

Windows 8 has gripper controls, which are a pair of transparent windows displaying gripper visuals and sending touch manipulation events back to the host, e.g., RichEdit. RichEdit 8 supports the following touch operations:

  • Smart caret placement on tap (snaps to the nearest word boundary)
  • Dragging the gripper extends or adjusts the selection
  • Tap on selection or gripper as well as Press and Hold brings up the context menu

When read-only mode is active, the behavior is modified so that a tap on a link activates the link and a tap on text selects a word.

In addition to combining touch with keyboards as in the touch on-screen keyboard, one can combine touch with a stylus. Touch isn’t nearly as geometrically precise as a stylus. The two together can offer special functionality beyond what either can offer alone. For example, a touch can emulate a control key like ctrl or alt, while the stylus pinpoints the location to be altered/interrogated. Multitouch is already being used widely in zoom/expand, scrolling and other ways. Imagine the number of possibilities with multitouch and a stylus! People who are musically inclined and gamers have the dexterity to perform all sorts of amazing interactions. These possibilities are beyond what’s supported by RichEdit 8, but are certainly exciting prospects for the future.