0 votes

Hi everyone,

is there any way to have the movement of the pressed mouse (or held down finger on a touchscreen) recognized in terms of "I just slid into the Area2D from the outside" and respectively "I was inside the Area2D and just slid outside"...?
I would like to not accept input anymore when sliding into or out of the Area2D, but to basically make the pressed state then being ignored. (Hope that makes sense...)

Any suggestions?

in Engine by (365 points)

The standard mouse_entered() and mouse_exited() signals of the Area2D will register the just slid inside and just slid outside the Area2D much as you described - regardless of the state of the mouse button(s) when the signal is triggered. So, that seems to solve part of your question, but you seem to be after more than just that. I don't really follow any more of the question.

Again you can read my mind and understand it better than I do...

Trying out all these functions of a button I'd like to create makes me stumble over all kinds of little issues whenever I thought I nailed something, so in this case, following your suggestions on earlier questions, I felt like I needed the state of mouse_entered/exited "remembered and forgotten" at the same time, which wouldn't work.

So I came up with a combination of my earlier approach of a "run-until-the-end-timer" and your suggested "quit-when-release-timer" and... nailed it! (For now.) I uploaded an example here: https://we.tl/t-SUiz37CsN2 so please feel free to check it out (and optimize to your liking if you want to : )

What I had a hard time to solve in the end was occasional inputs outside the Area2D and signals automatically following yields where they shouldn't etc., but now everything seems to work just fine. It's hacky without a doubt and I am absolutely sure that there are much more elegant ways to achieve the same result, but my beginner-ambitions certainly are very satisfied for the moment.
On to the next challenge! (Which will be this functionality put on a checkbox-button...)

Glad you got things working. I'll try to check out your project sometime soon.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.