.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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT