When I use mouse LESTONER and I check for a middle mouse button, it does not respond properly I do not know why, but it seems as if I need to scroll through walking to get an event to be part of my code, if it is
public zero With mouse mouse (mouse everne e) {if (new rectangle (0,0,1274, 30) is included (Screen. MSE)) {top menu.click (); } And if (new rectangle (0,31,1100,549) is included (screen. Mse)) {Map.cliked (e.getButton (), 0); Println ("mouse:" + e.getButton ()); } And if (new rectangle is included (1100,30,174,550) (screen.m se)) {// cliked modeMenu} and if (new rectangle (0,580,1100,164) is included (screen .mse)) // Cliked ToolsMenu} Else {// cliked mode change} switch (E. Megadometrie ()) {case InputEvent.BUTTON1_MASK: {System.out.println ("This is the left button"); break; } Case InputEvent.BUTTON2_MASK: {System.out.println ("This is a middle button"); break; } Case InputEvent.BUTTON3_MASK: {System.out.println ("This is the right button"); break; If you see javadox for MouseEvent, you can see BUTTON1. , BUTTON2 and BUTTON3 are not called left, middle and right mouse buttons. It depends on the mouse whether the buttons are 1,2 and 3, so that BUTTON2 does not mention the middle button. To see if the button between your mouse has been detected correctly, try the following: with a public Zero mouse mouse (mouseover-e) {System.out.println (e. GetButton ()); } Now press your middle mouse button. If there is no output in the console, then your mouse has no middle button (or it has not been recognized properly). If there is an output, then it matches the button (1 = BUTTON1,2 = BUTTON2,3 = BUTTON3). If the output is 0, then the button is mouse event. Noboton, which is unlikely to happen.
One more thing: try using SwingUtilities.isMiddleButton (MouseEvent E). This can fix some problems with your mouse. If you do this, keep your mouseclient () method on
public zero mouseclutter (if it is (swinguals.littmosbutton ( E)) {System.out.println ("this is the left button");} and if (swing utes. Isimlomz button (e)) {System.out.println ("this is middle button");} and if (SwingUtilities .isRightMouseButton (e)) {System.out.println ("This is the right button")}} (Exactly with all the other code written above the original code )
No comments:
Post a Comment