Adapting UI of Windows 8 app for available pointer devices

November 08, 2012
Windows 8 WinRT
 

Below you can see screenshots of Microsoft Word 2013 main menu taken on three different systems: desktop PC, Ultrabook and tablet.

Word 2013

All three screenshots look different and here is why. Although Word 2013 is a desktop application, all Office 2013 applications are optimized for supporting touch-enabled systems. When Word detects that system is equipped with a touch device, such as tablet or Ultrabook touch screen, it displays additional button.

Word 2013

And even more, if no mouse is connected to a tablet, Word switches UI in touch-optimized mode. In contrast, Ultrabook has trackpad so Word stays in mouse-centric mode, allowing user to enable touch mode manually.

Usually Windows 8 Store apps do not require special logic for touch and mouse devices – they have to handle all pointer devices. But there are scenarios when apps can benefit from knowing about available devices. For example, an app may show simplified interface when tablet is used outside of office and full UI when mouse and keyboard are attached.

WinRT includes several classes that allow to identify attached input devices: TouchCapabilities, MouseCapabilities and KeyboardCapabilities


var mouseCapabilities = new Windows.Devices.Input.MouseCapabilities();
bool mousePresent = mouseCapabilities.MousePresent > 0;

var touchCapabilities = new Windows.Devices.Input.TouchCapabilities();
bool touchPresent = touchCapabilities.TouchPresent > 0;

By checking these properties apps can easily adapt user interface to maximize data input efficiency.

blog comments powered by Disqus