October 24, 2016
Hot Topics:

User Code: Mouse Hex Value Check

  • April 19, 2001
  • By Corey Livermore
  • Send Email »
  • More Articles »

This simple routine will check the Hex value of the mouse button being pressed and will send output to the system output telling you which button has been pressed. This can be changed so you can have other tasks done when the left or right mouse button is pressed. Note: This only works for two-button mice.

 private void Form2_mouseDown(Object source, MouseEvent e)
 int Mouse = e.button;
 Integer MyMouse = new Integer(Mouse);
 String MouseHex = MyMouse.toHexString(Mouse);
 String MouseL = "1000000";

 if (MouseHex.compareTo(MouseL) < 0)
 System.out.println("Left Mouse Button");
 System.out.println("Right Mouse Button.");

That's it.

[To contribute a code article to Gamelan, please contact kmurphy@internet.com.]

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel