UpdateSampleResults("Left Button Pressed") If Mouse.LeftButton = MouseButtonState.Pressed Then if (Mouse.LeftButton = MouseButtonState.Pressed) The following example determines whether the LeftButton on the mouse is in the Pressed state. If (Keyboard.GetKeyStates(Key.Return) And KeyStates.Down) > 0 ThenĮxamples of input API on the Mouse class are MiddleButton, which obtains the state of the middle mouse button, and DirectlyOver, which gets the element the mouse pointer is currently over. ' A bitwise AND operation is used in the comparison. ' Uses the Keyboard.GetKeyStates to determine if a key is down. If ((Keyboard.GetKeyStates(Key.Return) & KeyStates.Down) > 0) A bitwise AND operation is used in the comparison. Uses the Keyboard.GetKeyStates to determine if a key is down. The following example uses the GetKeyStates method to determine if a Key is in the down state. In addition to the input API on the base element classes, the Keyboard class and Mouse classes provide additional API for working with keyboard and mouse input.Įxamples of input API on the Keyboard class are the Modifiers property, which returns the ModifierKeys currently pressed, and the IsKeyDown method, which determines whether a specified key is pressed. Event routing in WPF is discussed in more detail later in this overview and in the Routed Events Overview. Bubbling events bubble up from the target element to the root element. Preview events tunnel down the element tree from the root element to the target element. The difference in these events is in how they are routed to the target element. For example, the key down event is associated with the KeyDown and PreviewKeyDown events. Many input events have a pair of events associated with them. By placing the input API on the base elements, rather than treating all input events as a service, the input architecture enables the input events to be sourced by a particular object in the UI, and to support an event routing scheme whereby more than one element has an opportunity to handle an input event. These classes provide functionality for input events related to key presses, mouse buttons, mouse wheel, mouse movement, focus management, and mouse capture, to name a few. For more information about the base elements, see Base Elements Overview. The primary input API exposure is found on the base element classes: UIElement, ContentElement, FrameworkElement, and FrameworkContentElement. The WPF and explains the architecture of the input systems.
0 Comments
Leave a Reply. |