Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q4027 How do I capture mouse button events?

You are here: irt.org | FAQ | Java | Q4027 [ previous next ]

public boolean handleEvent(Event evt) {
    switch(evt.id) 
        {
           case Event.MOUSE_DOWN:
              if(evt.modifiers == evt.CTRL_MASK) {
                 System.out.println("Right button pressed");
              } 
              else {
                 if (evt.modifiers == evt.ALT_MASK) {
                    System.out.println("Middle btn pressed");
                 } 
                 else {
                    System.out.println("Left button pressed");
                 }
              }
       
              return true;
        }

    return super.handleEvent(evt);
}

©2018 Martin Webb