Skip to content

Commit d13b459

Browse files
committed
fix: Right-clicking in modern Java
1 parent dcca2b7 commit d13b459

1 file changed

Lines changed: 31 additions & 11 deletions

File tree

src/main/java/jagex2/client/GameShell.java

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,25 +317,45 @@ public void mousePressed(MouseEvent e) {
317317
this.nextMouseClickY = y;
318318
this.nextMouseClickTime = System.currentTimeMillis();
319319

320-
if (e.isMetaDown()) {
321-
this.nextMouseClickButton = 2;
322-
this.mouseButton = 2;
323-
} else {
324-
this.nextMouseClickButton = 1;
325-
this.mouseButton = 1;
326-
}
320+
try {
321+
if (e.getButton() == MouseEvent.BUTTON3) {
322+
this.nextMouseClickButton = 2;
323+
this.mouseButton = 2;
324+
} else {
325+
this.nextMouseClickButton = 1;
326+
this.mouseButton = 1;
327+
}
327328

328-
if (InputTracking.enabled) {
329-
InputTracking.mousePressed(y, e.isMetaDown() ? 1 : 0, x);
329+
if (InputTracking.enabled) {
330+
InputTracking.mousePressed(y, e.getButton() == MouseEvent.BUTTON3 ? 1 : 0, x);
331+
}
332+
} catch (NoSuchMethodError ex) {
333+
if (e.isMetaDown()) {
334+
this.nextMouseClickButton = 2;
335+
this.mouseButton = 2;
336+
} else {
337+
this.nextMouseClickButton = 1;
338+
this.mouseButton = 1;
339+
}
340+
341+
if (InputTracking.enabled) {
342+
InputTracking.mousePressed(y, e.isMetaDown() ? 1 : 0, x);
343+
}
330344
}
331345
}
332346

333347
public void mouseReleased(MouseEvent e) {
334348
this.idleCycles = 0;
335349
this.mouseButton = 0;
336350

337-
if (InputTracking.enabled) {
338-
InputTracking.mouseReleased(e.isMetaDown() ? 1 : 0);
351+
try {
352+
if (InputTracking.enabled) {
353+
InputTracking.mouseReleased(e.getButton() == MouseEvent.BUTTON3 ? 1 : 0);
354+
}
355+
} catch (NoSuchMethodError ex) {
356+
if (InputTracking.enabled) {
357+
InputTracking.mouseReleased(e.isMetaDown() ? 1 : 0);
358+
}
339359
}
340360
}
341361

0 commit comments

Comments
 (0)