środa, 4 kwietnia 2012

Notatki o Windows 8 Consumer Preview - odc.7

Dziś o obsłudze wejścia (dotyku, myszy, pióra, klawiatury), a także na temat samych gestów, manipulacji i interakcji.

W przypadku przesuwania/scrollowania są wyszczególnione trzy rodzaje: wzdłuż pojedynczej osi, wzdłuż "szyn” oraz we wszystkich kierunkach. Więcej informacji mamy o tzw. “snap points” - wybierane dzięki bliskości lub obowiązkowo. Dostajemy zalecenia do realizacji różnych scenariuszy.

Przez CSS możemy też wpływać na sposób zaznaczania elementów (np. tekstu i obrazków).

W przypadku elementów o rozmiarach mniejszych niż zalecane do obsługi przez dotyk (np. linki na stronie, pozycje w kalendarzu, pozycje w combobox) system dostarcza wsparcia, by korzystało się z nich łatwiejszy sposób.

System dostarcza też tzw.tethering, który polega możliwości operowania na obiekcie nie mając z nim bezpośredniej styczności przy wizualnej podpowiedzi łączącej miejsce dotyku z obramowaniem obiektu.

Możliwy jest również tzw.scrubbing - dotknięcie w obszarze obiektów docelowych i bez podnoszenia palca wybór obiektu.

W interakcji użyteczne z pewnością są tooltipy, "bogate” tooltipy i menu kontekstowe. Otrzymujemy zalecenia do różnych przypadków użycia tych elementów.

Na tle obsługi pointer-ów w JS moją uwagę teraz zwróciła informacja, że oprócz prostych gestów i rozpoznawania ich źródła (mysz, dotyk, pióro), mamy także oddzielną przestrzeń nazw, w której zawarte jest wsparcie dla bardziej złożonych gestów, manipulacji, łącznie z obsługą inercji!

W przypadku klawiatury pewnym usystematyzowaniem jest informacja o dwóch klawiaturach programowych. SIP dla pól tekstowych nie jest pełnoprawnym odpowiednikiem klawiatury sprzętowej.

Ciekawe są informacje na temat zapisywania i odczytywania danych wprowadzanych przez pióro elektroniczne! Obecnie wspierany jest zapis metadanych ISF do formatu GIF (przyjazny dla HTML), dane ISF odczytywać możemy z większej ilości formatów.

Uporządkowany został temat związany z gestami, manipulacjami i interakcjami. Wyróżniamy gesty takie jak: tap, press-and-hold, slide (długie przesunięcie), swipe (krótkie przesunięcie), rotate, pinch, stretch. Mamy wyszczególnionych i opisanych kilka popularnych interakcji:  learning, commanding, panning, zooming (optical zooming, resizing, and semantic zooming), rotating, selecting & moving, displaying command bars.

Pojawiła się sekcja dla obsługi wejścia przez głos, ale na razie z adnotacją, że w obecnej wersji nie jest to wspierane.

JS

Responding to user interaction

The gesture recognition engine can also process custom gestures for interaction scenarios that are not supported by the Windows gestures. However, we recommend that you do not customize the behavior of the basic Windows gestures, as this can create an inconsistent and confusing user experience.

Feedback behavior is intrinsic to the Windows 8 user experience and cannot be disabled in Metro style apps using JavaScript.

Guidelines

Cross-slide

Cross-slide is the touch-optimized technique used by Metro style apps in Windows 8 Consumer Preview for selecting or dragging-and-dropping an item within a content area that is pannable in one dimension (vertical or horizontal).

Screen shot showing the animation for selection.

Drag down to select. Self-revealing interaction demonstrates what action will be performed. Continue to drag down and the self-revealing image changes to show that the object can now be dragged and dropped.  In addition to the cross-slide interaction, a single tap interaction can be used for selection in applications where selection is the only primary action that can be performed.

Selection basket

This feature is useful for tracking selected items and should be used by applications where:

  • Items can be selected from multiple locations.
  • Many items can be selected.
  • An action or command relies upon the selection list.

Items in the selection basket can be removed with a cross-slide selection interaction on the item in the basket. This, in turn, cancels the selection of the corresponding item in the primary list. Canceling the selection in the primary list removes the item from the basket.

The selection basket also enables a user to select and cancel all items in the current list or collection at once by using a single interaction.

Queues

A queue is not equivalent to the selection basket list and should not be treated as such. The primary distinctions include:

  • The list of items in the selection basket is only a visual representation; the items in a queue are assembled with a specific action in mind.
  • Items can be represented only once in the selection basket but multiple times in a queue.
  • The order of items in the selection basket represents the order of selection. The order of items in a queue is directly related to functionality.

For these reasons, the cross-slide selection interaction should not be used to add items to a queue. Instead, items should be added to a queue through a drag-and-drop action.

Optical zoom and resizing

Optical zoom is supported only by non-replaced elements; it is not supported by replaced elements (those outside the scope of the CSS formatter, such as an image, embedded document, or applet). For a replaced element to support optical zoom, the -ms-content-zooming style must be applied to a non-replaced parent element.

Panning

The scroll control

The scroll control provides assistance to users for panning or scrolling a view. It is exposed to Metro style app using JavaScript developers at design time through Cascading Style Sheets (CSS) only. This control has two modes:

  • Panning indicators when using touch.
  • Scroll bars when using other input methods that include mouse, keyboard and stylus.

The modes are managed by the control, and don't require any work by the developer.

Note  The scroll control is a just-in-time control: the panning indicator is only visible when the touch contact is within the pannable region. Similarly, the scroll bar is only visible when the mouse cursor or keyboard focus is within the scrollable region.

Types of panning

Windows 8 Consumer Preview supports three types of panning:

  • Single axis - panning is supported in one direction only (horizontal or vertical).
  • Rails - panning is supported in all directions. However, once the user crosses a distance threshold in a specific direction, then panning is restricted to that axis.
  • Freeform - panning is supported in all directions.
Snap points

Snap points can be used to influence panning behavior by providing logical points within the content at which to stop panning and ensure a specific subset of content is displayed in the viewport. Cognitively, snap points act as a paging mechanism for the user.

In addition, users tend to physically tire of excessive sliding or swiping in large pannable areas. Snap points enable users to be imprecise and still achieve their goals.

There are two types of snap-points:

  • Proximity - After the contact is lifted, a snap point is selected if inertia stops within a distance threshold of the snap point.
  • Mandatory - The snap point selected is the one that immediately precedes or succeeds (depending on the direction of the gesture) the last snap point crossed before the contact was lifted. A snap point cannot be skipped due to inertia.

Panning snap-points are useful for applications such as web browsers and photo albums that emulate paginated content or have logical groupings of items that can be dynamically regrouped to fit within a viewport or display.

Rails

It is common for webpages to be wider and taller than the screen of a display device. For this reason, two-dimensional panning (horizontal and vertical) is often necessary. To improve the user experience in these cases, rails encourage panning in one dimension while locking out panning in the other dimension. This is accomplished by providing horizontal and vertical boundaries (rails) where panning is constrained unless the user drags a finger to exit the rail.

One-dimensional overflow

Use one-dimensional panning when the content area extends beyond the viewport along a single axis.

  • Use vertical panning for a one-dimensional list of items.
  • Use horizontal panning for a grid of items.

Don’t use mandatory snap-points if a user should be able to pan and stop between snap-points. Mandatory snap-points guarantee that the user will “stop” on a snap-point. Use proximity snap-points instead.

Two-dimensional overflow

Use two-dimensional panning when the content area extends beyond the viewport along both axes.

  • Override the default rails behavior and use freeform panning for unstructured content where the user is likely to move in multiple directions. For example, freeform panning is typically suited to photographs or maps.
Paged view

Use mandatory snap-points when the content is composed of discrete elements or you want to display an entire element. This can include pages of a book or magazine, a column of items, or individual images.

  • A snap-point should be placed at each logical boundary.
  • Each element should be sized to fit the view.
Logical and key points

Use proximity snap-points if there are key points or logical places in the content that a user will likely stop.

  • A snap-point should be placed at each section header.
Panning indicators and scroll bars

Display panning indicators and scroll bars to provide location and size cues. Hide them if the application provides a custom navigation feature.

Note  Unlike standard scroll bars, panning indicators are purely informative. They are not exposed to input devices and cannot be manipulated in any way.

<style type="text/css"> #Div1 { overflow: scroll; }</style></head><body> <div id="Div1"> test </div></body>

<style type="text/css"> #Div1 { scrollbar-face-color:#903030; scrollbar-arrow-color:#FFFFFF; scrollbar-track-color:#C0B0B0; scrollbar-highlight-color:rgb(0,0,0); }</style></head><body> <div id="Div1"> test </div></body>

Rotation

Windows 8 supports three types of rotation: free, constrained, and combined.

Free rotation

Free rotation enables a user to rotate content freely anywhere in a 360 degree arc. When the user releases the object, the object remains in the chosen position. Free rotation is useful for drawing and layout applications such as Microsoft PowerPoint, Word, Visio, and Paint; and Adobe Photoshop, Illustrator, and Flash.

Constrained rotation

Constrained rotation supports free rotation during the manipulation but enforces snap points at 90 degree increments (0, 90, 180, and 270) upon release. When the user releases the object, the object automatically rotates to the nearest snap point.

Constrained rotation is the most common method of rotation, and it functions in a similar way to scrolling content. Snap points let a user be imprecise and still achieve their goal. Constrained rotation is useful for applications such as web browsers and photo albums.

Combined rotation

Combined rotation supports free rotation with zones (similar to rails in panning) at each of the 90 degree snap points enforced by constrained rotation. If the user releases the object outside of one of 90 degree zones, the object remains in that position; otherwise, the object automatically rotates to a snap point.

Semantic Zoom

A smooth cross-fade and scale animation is used for the transition from one semantic zoom level to another. This is the default Windows Touch behavior and cannot be customized.

Selecting text and images

Grippers are used for text selection, media controls, resizing, and image cropping.

Tap within the selection or on a gripper to invoke the context menu.

When using standard Windows 8 text controls, the selection behaviors and visuals described in this topic cannot be customized. However, it is possible to disable this functionality within your Metro style apps using JavaScript.

How to disable text and image selection

By default, all content in the UI of a Metro style app using JavaScript can be selected by a user and copied to the clipboard. However, access to UI elements (such as text, images, and other proprietary content) can be limited by excluding them from this default behavior through a single Cascading Style Sheets (CSS) property: -ms-user-select.

The -ms-user-select property supports the following values:

none

Selection is not possible within the element. However, the element itself can be included within a selection.

element

Selection is possible within the element (and all child elements). However, the selection is constrained to the bounds of the element. This is the default behavior for editable UI elements such as input fields and text areas in your app.

text

Selection is possible within the element and is not constrained to the bounds of the element. This is the default behavior for all non-editable UI elements in your app.

We recommend that you also set the value of the cursor property to default to ensure consistent UI feedback across all elements.

html{ -ms-user-select: none; cursor: default;}

#selectableDiv { -ms-user-select: element; cursor: text;}

Targeting

Targeting assistance

Windows provides targeting assistance to support scenarios where the minimum size or padding recommendations presented here are not applicable; for example, hyperlinks on a webpage, calendar controls, drop down lists and combo boxes, or text selection.

These targeting platform improvements and user interface behaviors work together with visual feedback to improve user accuracy and confidence.

Tethering

Tethering is a visual cue (a connector from a contact point to the bounding rectangle of an object) used to indicate to a user that they are connected to, and interacting with, an object even though the input contact isn't directly in contact with the object. This can occur when:

  • A touch contact was first detected within some proximity threshold to an object and this object was identified as the most likely target of the contact.
  • A touch contact was moved off an object but the contact is still within a proximity threshold.

Hh465342.vis_tether(en-us,WIN.10).png

This feature is not exposed to Metro style app using JavaScript developers.

Scrubbing

Scrubbing means to touch anywhere within a field of targets and slide to select the desired target without lifting the finger until it is over the desired target. This is also referred to as "take-off activation", where the object that is activated is the one that was last touched when the finger was lifted from the screen.

Visual feedback 

  • Do not show visual feedback during panning or dragging; the actual movement of the object on the screen is sufficient. However, if the content area does not pan or scroll, then you should use touch visualizations to indicate the boundary conditions.
  • Show the "tether" visualization when the finger is dragged off the element, but not lifted, to demonstrate that the element is still the active element.
Informational user interface

Informational UI, also known as disambiguation UI, helps overcome fingertip occlusion, displays information about an object, and describes functionality and how to access it. Tooltips, rich tooltips, and context menus are used to implement this touch feature.

A timed interaction, touch-and-hold, is dedicated to the display of informational UI. A timed interaction is acceptable in this case as it acts as a tool for learning and exploration.

Occlusion tooltips for scrubbing and small targets

These tooltips should describe the occluded target. These tooltips are useful when targeting and activating items smaller than a standard touch target size, such as hyperlinks on a webpage.

These tooltips may be replaced by an informational pop-up after a certain time threshold has passed. After this initial threshold, the tooltip should follow the behavior of the informational pop-up. For example, this would be used in a browser where the occlusion tooltip shows the occluded text and, after the time threshold, then shows the full URL.

Occlusion tooltips for actions and commands

These tooltips should describe the action that occurs when the finger is released from an element. These tooltips are useful when targeting and activating a button or similar control, as shown in the following screen shot.

It is acceptable for a small-target tooltip to be followed by an action tooltip after a certain time threshold has passed. In this case, the small-target tooltip should expand to include the additional information in the action tooltip.

Rich tooltip or informational pop-up

These tooltips should reveal secondary information about an element. For example, a rich tooltip could be a text description of an image, the full text of a truncated title, or other information relevant to the target. The following screen shot shows an example of a rich tooltip that contains information about a photograph.

Rich tooltips or information pop-ups typically contain information that does not need to be made available immediately and, in some cases, might be distracting if shown too quickly. A longer time threshold lets users be more deliberate about obtaining the information.

After a rich tooltip is displayed, the object is no longer activated when the user lifts their finger. The reason for this is that information gleaned from the tooltip might influence the user to not to activate the item.

We recommend that the visual design and information in the rich tooltip be distinct and more substantial than that of a standard tooltip.

Self-revealing interactions

A self-revealing interaction is an informative visual cue (or animation) that demonstrates how to perform an action with a target object and provides a preview of the result of that action.

The following image shows the self-revealing interaction for a cross-slide selection in a photo album application. When a user touches a photograph in the photo album (without dragging the photograph) the photograph slides down (as if being dragged) to reveal the selection check mark that would appear if the photograph were dragged to the selection basket.

Screen shot showing a self-revealing gesture animation.

After a self-revealing interaction is displayed, the object is no longer activated when the user lifts their finger.

Context menu

The touch-optimized context menu is composed of two parts. A visual cue, the hint, is displayed as a result of a hold interaction. Then, the context menu itself is displayed after the hint disappears and the finger is lifted.

The context menu should be used only where selection is not possible.

Introducing pointer input and devices

Pointer events

There is an extensive set of pointer-based input APIs that can intercept input data directly from various devices. You can handle pointer events to detect simple, one-finger interactions such as tap or handle manipulation events for more elaborate interactions including multi-touch interactions and interactions that use inertia and velocity data.

Metro style apps using JavaScript

The Metro style app using JavaScript APIs are exposed through the following namespaces:

Windows.Devices.Input

Provides support for identifying the input devices available (pointer, touch, mouse, and keyboard) and retrieving information about those devices.

Windows.UI.Core

Provides support for creating app windows, managing window interaction, and processing input events on those windows. Specifically, this namespace contains APIs that support both touch hit testing and pointer events.

Windows.UI.Input

Provides support for the Windows input system. This includes: gesture and manipulation detection, recognition, and handling; inertia detection, configuration, and handling; and pointer management.

Keyboard input

In addition to a hardware keyboard, Windows 8 provides two software keyboards:

  • The On-Screen Keyboard is intended for systems that don't have a physical keyboard, or for users whose mobility impairments prevent them from using traditional physical input devices. The On-Screen Keyboard emulates most, if not all, the functionality of a hardware keyboard.
  • The touch keyboard Soft Input Panel (SIP) is not a replacement for the accessibility On-Screen Keyboard SIP. The touch keyboard is for text input only (it does not emulate the hardware keyboard) and appears only when an editable input field gets focus.

    Note  the On-Screen Keyboard has priority over the touch keyboard, which will not be shown if the On-Screen Keyboard is present.

Pen and stylus input

Digital ink functionality (such as drawing, note taking, annotating, and handwriting recognition) is most commonly associated with a pointer device such as a pen or stylus. However, the ink platform in Windows 8 also supports input from other pointer devices, including touch digitizers and mouse devices.

var inkManager = new Windows.UI.Input.Inking.InkManager();

inkCanvas = get("inkCanvas");inkContext = inkCanvas.getContext("2d");

inkCanvas.addEventListener("MSPointerDown", onPointerDown, false); inkCanvas.addEventListener("MSPointerMove", onPointerMove, false); inkCanvas.addEventListener("MSPointerUp", onPointerUp, false);

Szczegóły implementacyjne  na Quickstart: Capturing ink data

How to save ink data

This topic demonstrates how to save ink data by serializing it as Ink Serialized Format (ISF) metadata and embedding the metadata into a Graphics Interchange Format (GIF) file.

This process enables ink to be viewed in applications that are not ink-enabled while maintaining full fidelity for ink-enabled applications. This format is ideal for transporting ink content within an HTML file and making it usable by both ink and non-ink applications.

ISF is the most compact persistent representation of ink. It can be embedded within a binary document format or placed directly on the Clipboard while preserving various ink properties such as pressure, width, color, tilt, twist, and so on.

inkManager.saveAsync(saveStream);

GIF is the only supported format for saving ink data in Windows 8 Consumer Preview.

How to load ink data

This topic demonstrates how to load ink data by de-serializing it from Ink Serialized Format (ISF) metadata embedded in a Graphics Interchange Format (GIF) file.

ISF is the most compact persistent representation of ink. It can be embedded within a binary document format or placed directly on the Clipboard while preserving various ink properties such as pressure, width, color, tilt, twist, and so on.

inkManager.loadAsync(loadStream);

GIF is the only supported format for saving ink data in Windows 8 Consumer Preview, however, the LoadAsync method does support the following formats for backward compatibility:

  • InkSerializedFormat - Specifies ink that is persisted using Ink Serialized Format (ISF). This is the most compact persistent representation of ink. It can be embedded within a binary document format or placed directly on the Clipboard.
  • Base64InkSerializedFormat - Specifies ink that is persisted by encoding the ISF as a base64 stream. This format is provided so ink can be encoded directly in an Extensible Markup Language (XML) or HTML file.
  • Gif - Specifies ink that is persisted by using a Graphics Interchange Format (GIF) file that contains ISF as metadata embedded within the file. This enables ink to be viewed in applications that are not ink-enabled and maintain its full ink fidelity when it returns to an ink-enabled application. This format is ideal when transporting ink content within an HTML file and making it usable by ink and non-ink applications.
  • Base64Gif - Specifies ink that is persisted by using a base64-encoded fortified GIF. This format is provided when ink is to be encoded directly in an XML or HTML file with later conversion into an image. A possible use of this is in an XML format that is generated to contain all ink information and used as a way to generate HTML through Extensible Stylesheet Language Transformations (XSLT).

Touch input

Windows 8 relies on a basic set of gestures to manipulate the UI and perform touch interactions.

  • Tap – One finger touches the screen and lifts up.
  • Press and hold - One finger touches the screen and stays in place.
  • Slide - One or more fingers touch the screen and move in the same direction.
  • Swipe - One or more fingers touch the screen and move a short distance in the same direction.
  • Rotate - Two or more fingers touch the screen and move in a clockwise or counter-clockwise arc.
  • Pinch - Two or more fingers touch the screen and move closer together.
  • Stretch - Two or more fingers touch the screen and move farther apart.

Manipulations & interactions

A manipulation is the reaction or response of an object or UI to a gesture. For example, both the slide and swipe gestures typically cause an element or UI to move in some way. The result of a manipulation, how it is manifested by the object on the screen and through the UI, is the interaction. The touch interactions have a direct affect on elements and UI and are considered direct manipulations. By contrast, interacting with an object through its properties window or other dialog box is considered indirect manipulation.

An interaction is based on how a manipulation is interpreted and the command or action that results from the manipulation. For example, both the slide and swipe gestures can move an object but the results are completely different depending on whether a distance threshold is crossed. Slide can be used to drag and drop an object or pan a view while swipe can be used to select an item or display the AppBar.

Some common interactions used in Windows 8:

Learning

The press and hold gesture is used to display detailed information or teaching visuals (for example, a tooltip or context menu) without committing to an action or command. Panning is still possible if a sliding gesture is initiated while the visual is displayed.

Learn interaction

Commanding

The tap gesture is used to invoke a primary action, for instance launching an application or executing a command.

Hh761498.touch_tap_primary(en-us,WIN.10).png

Panning

The slide gesture is used primarily for panning interactions but can also be used for moving, drawing, or writing. Panning is a touch-optimized technique for navigating short distances and small sets of content within a single view (such as the folder structure of a computer, a library of documents, or a photo album). Equivalent to scrolling with a mouse or keyboard, panning is only necessary when the amount of content in the view causes the content area to overflow the viewable area.

Panning interaction

Zooming

The pinch and stretch gestures are used for three types of interactions: optical zooming, resizing, and semantic zooming.

Semantic zoom is a touch-optimized technique for presenting and navigating structured data or content within a single view (such as the folder structure of a computer, a library of documents, or a photo album) without the need for panning, scrolling, or tree view controls.

Rotating
Selecting and moving

The slide and swipe gestures are used in a cross-slide manipulation, a movement perpendicular to the panning direction of the content area. Windows interprets this as either a selection or, if a distance threshold is crossed, a drag-and-drop interaction.

Displaying command bars

The swipe gesture is used to reveal various command bars or the login screen.

App commands are revealed by swiping from the bottom or top edge of the screen. Use the AppBar to display app commands.

Display app commands

System commands are revealed by swiping from the right edge, recently used apps are revealed by swiping from the left edge, and swiping from the top edge to the bottom edge reveals docking or closing commands.

Display system commands

Interaction events

There are two types of event mechanisms for touch interactions in Windows 8:

  • Pointer events are used to support simple, one-finger interactions such as tapping (also referred to as static gestures).
  • Manipulation events are used for multi-touch interactions such as pinching, and interactions that use inertia and velocity data such as dragging.

Voice input

Metro style apps in Windows 8 Consumer Preview do not support user interactions through speech input. No public APIs are exposed for customizing this experience. This documentation is relevant for developers building Metro style apps for tablets and computers that have an attached voice digitizer that accepts speech input.

W XAML i C# dokumentacja jest dość odmienna.  Zdarzenia pointerów i manipulacji wydają się dość znajome z poprzedniej wersji. Obecnie zwracają uwagę nowe informacje na temat obsługi klawiatury. W obecnym wydaniu nie jest wspierany klawisz Alt, choć jest typ mający go reprezentować. Możliwa jest własna obsługa zmian w UI po wyświetlaniu się klawiatury dotykowej oraz implementacja własnej kontrolki tekstowej niedziedziczącej po TextBox z obsługą klawiatury dotykowej. Klawiatura dotykowa generuje te same zdarzenia, co sprzętowa, jedynie kombinacje z Ctrl odpowiedzialne za operacje na tekście nie są przechwytywane.

C# & XAML

Responding to user interaction

You can implement your own touch and interaction support, but keep in mind that users expect an intuitive experience involving direct interaction with the elements of your app. You should model your custom touch support on the built-in support in order to keep things simple and discoverable.

To use the built-in touch support, you can handle pointer events to detect simple, one-finger interactions such as tap. To use more elaborate interactions, handle the manipulation events, such as ManipulationStarted and ManipulationDelta. These provide access to multi-touch interactions and interactions that use inertia and velocity data.

Interactions

Interactions are a high-level way of interpreting touch input data into a set of common motions such as tapping, dragging, and pinching. Some common interactions used in Windows 8 are:

Tap - One finger touches the screen and lifts up.

Hold - One finger touches the screen and stays in place.

Drag - One or more fingers touch the screen and move in the same direction.

Pinch - Two or more fingers touch the screen and move closer together or farther apart.

Rotate - Two or more fingers touch the screen and move in a clockwise or counter-clockwise arc.

Cross-slide - One finger touches an object and drags it at a right angle to the panning direction.

Keyboard

All keyboard events use KeyEventArgs for event data, and KeyEventArgs contains the following properties:

Key

Key returns a VirtualKey value. The VirtualKey enumeration includes all the keys supported by Metro style apps using C++, C#, or Visual Basic.

Modifier keys

Modifier keys are keys such as Ctrl or Shift that users typically press in combination with other keys. Your app can use these combinations as keyboard shortcuts to invoke app commands.

In Metro style apps using C++, C#, or Visual Basic, you detect shortcut key combinations by using code in your KeyDown and KeyUp event handlers to track the pressed state of the modifier keys you are interested in. When a keyboard event occurs for a non-modifier key, you can check whether a modifier key is in the pressed state at the same time.

Note  The Alt key is represented by the VirtualKey.Menu value, but this value is not currently supported by Metro style apps using C++, C#, or Visual Basic.

The app will not raise input events until the user sets the input focus manually (for example, by tabbing to or clicking a control).

private void Grid_KeyDown(object sender, KeyEventArgs e){ if (e.Key == VirtualKey.Control) isCtrlKeyPressed = true; else if (isCtrlKeyPressed) { switch (e.Key) { case VirtualKey.P: DemoMovie.Play(); break; case VirtualKey.A: DemoMovie.Pause(); break; case VirtualKey.S: DemoMovie.Stop(); break; } }}

When the touch keyboard appears, it automatically repositions your UI to ensure that the focused element remains visible. This can cause other important areas of your UI to move off screen. However, you can disable the default behavior and make your own UI adjustments when the touch keyboard appears. For more info, see the Responding to the appearance of the on-screen keyboard sample.

If you create a custom control that requires text input but does not derive from a standard text input control, you can add touch keyboard support by implementing the correct UI Automation control patterns. For more info, see the Touch keyboard sample.

Key presses on the touch keyboard raise KeyDown and KeyUp events just like key presses on hardware keyboards. However, the touch keyboard will not raise input events for Ctrl+A, Ctrl+Z, Ctrl+X, Ctrl+C, and Ctrl+V, which are reserved for text manipulation in the input control.

Brak komentarzy: