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

Chapter 14. Other SWT Listeners > Responding to Shift-Click Events

14.4. Responding to Shift-Click Events

Sometimes you must respond to mouse events that occur in combination with keystrokes. For example, some interfaces select text when the user holds the Shift key while dragging the mouse. For these times, there must be a mechanism that enables you to determine if a key is being pressed simultaneously with a mouse button.

14.4.1. How do I do that?

For this purpose MouseEvent contains a field known as stateMask. This field is populated only when the user is holding down one of the keyboard keys at the same time the mouse is being clicked. If you want to code some action that occurs only when the user is holding the Shift key while clicking a mouse button:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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