0 votes

Hi, I want the mouse to be captured in a specific area, so not the whole screen. Is there a way to do this?

in Engine by (44 points)

You could check the mouse position and hide it when it matches the region. Do you also want the cursor to be stuck there or do you just want to hide it?

I want it to be stuck, so when you drag and drop an item you can't drag it out of the area.

Oh and you want the mouse to be stuck also, or only the thing you drag? If the mouse too, you could set the mouse position every frame http://docs.godotengine.org/en/latest/classes/class_viewport.html?highlight=get_mouse_pos#class-viewport-method-warp-mouse, but IMO it won't look nice (if not hidden).

So I have the drag and drop thing working but how do i keep the mouse in this new viewport?

Well I'm quite new too but I would say try that warp_mouse method to set the mouse cursor position every (physics)process while you want the cursor to be stuck.

Okay I'll figure that out thanks!

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.