• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 5. Display > Cursor Control and Location

5.12. Cursor Control and Location

Displays provide API to identify the control that has the cursor and get and set the location of the cursor. Because there is only one cursor on the desktop, it is shared by all applications. Moving the cursor on the display will move the cursor for every application on the desktop.

5.12.1. Getting the Cursor Control

At any time, the cursor can be over a control or the desktop. Although it is possible to write code that gets the list of shells and recursively queries the bounds of their children to find the child that is under the cursor, this is inefficient and can be problematic. When the user clicks or moves the mouse, the operating system determines where the mouse operation occurred. This process is called hit testing. Normally, mouse events are delivered to the deepest child in the hierarchy[9] but this is not always the case. For example, a control that is disabled does not receive mouse clicks, even though it may contain the cursor. This prevents the control from acting on a mouse click while it is disabled.

[9] In this case, we are talking about the containment hierarchy made up of controls and their children, so that the control that is returned would be the one that is under the cursor that does not have children that are also under the cursor.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint