orange451 1 Posted May 31, 2018 Hello, I am messing with keyevent's and mouseevent's in my script. They work perfectly fine for capturing the input, however, I am not able to cancel them from reaching the game. I've created a GUI that looks like this: All of the buttons function properly. HOWEVER, they still affect the game below. From the API of the MouseEvent and KeyEvent, if I call "consume()" it should block the event from reaching its source, but that does not seem to work properly. For example. If I press the X button on the window, I will start walking towards that red chair (even though the mouse event is consumed). Any help would be appreciated.
Scorpius 144 Posted May 31, 2018 Use this under an OnMouseEnter listener getClient().getInstance().setMouseInputEnabled(false); And this under an OnMouseExit listener getClient().getInstance().setMouseInputEnabled(true);
orange451 1 Author Posted May 31, 2018 @zScorpio That won't work. My gui isn't external. It's painted ontop of the client. There is no enter or exit event fired when mousing over it.
Scorpius 144 Posted May 31, 2018 1 minute ago, orange451 said: That won't work. My gui isn't external. It's painted ontop of the client. There is no enter or exit event fired when mousing over it. Make your own mouse listener and define the GUI box boundaries. Another option is to detect onMousePress (not onMouseClick) and do the mouse-disabling there Edit: I think by the time onMousePress gets called the click will be already sent to the game screen, so no this is probably not a solution.
orange451 1 Author Posted May 31, 2018 Furthermore, setMouseInputEnabled/Disabled() wont work because my gui solution relies on mouse input being enabled to read it in the first place. Like I said, it's not an external window. It's literally painted on top of the client. I really feel like event.consume() should be the appropriate way to solve this.
Scorpius 144 Posted May 31, 2018 Another way to achieve is this creating your GUI on a borderless frame/window instead of building it inside onPaint Edit: If your solution relies on the mouse input being enabled then you're doing something wrong. I remember being able to click on the GUI elements drawn via onPaint without any problems with the client's mouse input being enabled or not.
orange451 1 Author Posted May 31, 2018 Unfortunately, that would be a mess with positioning. I want it to feel like it's part of runescape. i.e. if the runescape window moves, any of my windows will move with it.
Scorpius 144 Posted May 31, 2018 2 minutes ago, orange451 said: Unfortunately, that would be a mess with positioning. I want it to feel like it's part of runescape. i.e. if the runescape window moves, any of my windows will move with it. You can achieve that via code as well, drag listeners.
orange451 1 Author Posted May 31, 2018 That's getting much more hacky than properly implementing a consumed event into the bot, no?
Scorpius 144 Posted May 31, 2018 5 minutes ago, orange451 said: That's getting much more hacky than properly implementing a consumed event into the bot, no? You're making a paint GUI that looks like runescape's original XD
Recommended Posts
Archived
This topic is now archived and is closed to further replies.