.NET
  Home arrow .NET arrow Page 2 - Mouse Input and the WPF
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Mouse Input and the WPF
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2008-07-02

    Table of Contents:
  • Mouse Input and the WPF
  • Mouse Input
  • Mouse Input and Hit Testing
  • Mouse State

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Mouse Input and the WPF - Mouse Input


    (Page 2 of 4 )

    Mouse input is directed to whichever element is directly under the mouse cursor. All user interface elements derive from the UIElement base class, which defines a number of mouse input events. These are listed in Table 4-1.

    Table 4-1. Mouse input events

    Event

    Routing

    Meaning

    GotMouseCapture

    Bubble

    Element captured the mouse.

    LostMouseCapture

    Bubble

    Element lost mouse capture.

    MouseEnter

    Direct

    Mouse pointer moved into element.

    MouseLeave

    Direct

    Mouse pointer moved out of element.

    PreviewMouseLeftButtonDown, MouseLeftButtonDown

    Tunnel, Bubble

    Left mouse button pressed while pointer inside element.

    PreviewMouseLeftButtonUp, MouseLeftButtonUp

    Tunnel, Bubble

    Left mouse button released while pointer inside element.

    PreviewMouseRightButtonDown, MouseRightButtonDown

    Tunnel, Bubble

    Right mouse button pressed while pointer inside element.

    PreviewMouseRightButtonUp, MouseRightButtonUp

    Tunnel, Bubble

    Right mouse button released while pointer inside element.

    PreviewMouseDown, MouseDown

    Tunnel, Bubble

    Mouse button pressed while pointer inside element (raised for any mouse button).

    PreviewMouseUp, MouseUp

    Tunnel, Bubble

    Mouse button released while pointer inside element (raised for any mouse button).

    PreviewMouseMove, MouseMove

    Tunnel, Bubble

    Mouse pointer moved while pointer inside element.

    PreviewMouseWheel, MouseWheel

    Tunnel, Bubble

    Mouse wheel moved while pointer inside element.

    QueryCursor

    Bubble

    Mouse cursor shape to be determined while pointer inside element.

    In addition to the mouse-related events,UIElementalso defines a pair of properties that indicate whether the mouse pointer is currently over the element:IsMouseOverandIsMouseDirectlyOver. The distinction between these two properties is that the former will be true if the cursor is over the element in question or over any of its child elements, but the latter will be true only if the cursor is over the element in question but not one of its children.

    Note that the basic set of mouse events shown in Table 4-1 does not include a Clickevent. This is because clicks are a higher-level concept than basic mouse input—a button can be “clicked” with the mouse, the stylus, the keyboard, or through the Windows accessibility API. Moreover, clicking doesn’t necessarily correspond directly to a single mouse event—usually, the user has to press and release the mouse button while the mouse is over the control to register as a click. Accordingly, these higher-level events are provided by more specialized element types. TheControl class adds aPreviewMouseDoubleClickandMouseDoubleClick event pair. Likewise,ButtonBase—the base class ofButton,CheckBox, andRadioButton—goes on to add aClick event.

    More .NET Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Programming WPF, Second Edition,"...
     

    Buy this book now. This article is excerpted from Programming WPF, Second Edition, written by Chris Sells and Ian Griffiths (O'Reilly, 2007; ISBN: 0596510373). Check it out today at your favorite bookstore. Buy this book now.

    .NET ARTICLES

    - Building Applications with Windows Workflow ...
    - Building the Data and Business Layers Using ...
    - The Transformed XML Explorer in MFC
    - List Control and Property Grid with the MFC ...
    - Font, Shell and Masked Edit Controls for MFC
    - Color, Link and Image Editor Controls for M...
    - New Controls for MFC
    - The Windows Ribbon Framework
    - Markup Language for the Ribbon Framework
    - Visually Upgrade Your MFC Project
    - New Features for the Statusbar in MFC
    - Working with the Statusbar in MFC
    - Iron Speed Design v60 Review
    - Binary and XML Serialization
    - Using CrystalReportViewer to Display Crystal...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek