arowar 0 Share Posted July 6, 2020 Hey fellow scripters I'm trying to catch mouseevents from the user while a script is running but my mouselistener seems to only catch events from the mousepointer that is used ingame (i.e. the mousepointer my script uses). I'm trying to make an interactive paint that can change state when a user clicks on a graphic without interrupting my script. Any ideas? Link to comment Share on other sites More sharing options...
Xtra 31 Share Posted July 6, 2020 I may have missed something, but here's an example to toggle your paint, you can use this to work out how an interaction works /* In your main class * Use IDE to implement the methods * Here is an example for toggling your paint without interrupting the script */ public class main extends AbstractScript implements MouseListener { private Boolean hidePaint = false; private Rectangle rect = new Rectangle(504, 340, 15, 15); private Rectangle closePaint = rect; private Rectangle openPaint = rect; private point p; // In your onPaint() public void onPaint(Graphics g) { if (!hidePaint) { // Code to show your paint } else { // Code to show another custom image which doesn't cover chat } } @Override public void mouseClicked(MouseEvent e) { p = e.getPoint(); if (closePaint.contains(p) && !hidePaint) { hidePaint = true; } else if (openPaint.contains(p) && hidePaint) { hidePaint = false; } } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } } Link to comment Share on other sites More sharing options...
arowar 0 Author Share Posted July 6, 2020 i've implemented this in a similar way but i don't get an event when the script is running (user input is disabled) p = new ExtenderPainter(hm); //extends MouseListener main.getClient().getInstance().addEventListener(p); -- //in ExtenderPainter @Override public void mouseClicked(MouseEvent e) { hm.log("event fired"); PainterPane clickedPane = panes.stream().filter(p -> p.containsPoint(e.getPoint())).findFirst().orElse(null); if(clickedPane != null) { clickedPane.open(); } } I only get this log message when I enable user input (interfering with the script) Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted July 7, 2020 I assume the mouse listeners only detects the mouse events when the mouse interacts with the game canvas (which doesn't occur when user input is disabled) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.