How to disable mouse navigation?

Can anyone tell me, if it´s possible to disable the mouse navigation function?
So that nothing happens, when you click and drag on the background.
Is this possible?

1 Like
Input.onKeyPressed(function(){},'left_mouse_button');

ie, when the left mouse button is pressed, do nothing (empty function).

Geoff @ TechLeap

1 Like

Thanks Geoff.
However, I need to be able to still click on objects with the mouse.
I´m sorry that was not clear in the original post.
Is there a way to do this?

Yes, but it’s a little trickier as you need to delve into the RayCast API:

Input.onKeyPressed(function(){
    const rayCastHit = RayCast.cast( Camera.transform.position, Input.clickDirection );
    if (rayCastHit && rayCastHit.item.name === "Cuboid"){
        rayCastHit.item.input.onClick(function(){
            // do something for this Cuboid
        });
    }
},'left_mouse_button');

This basically says if you’re not clicking on an Item, do nothing. However, you may only want certain items to be clickable, in which case you will need to specify the item (in my case, a Cuboid) and what you want to happen to it.

@Nikolay, is it possible to see whether Items already have event listeners attached (e.g. within CoBlocks, or previously set in JS/TS)? I’m guessing not.

Hope that helps! Let me know if you have any further questions.

Geoff @ TechLeap

Hi @techleapnz,

at the moment you cannot get a list of listeners.

1 Like

If you don’t want a camera to be able to look around, put a set rotation block in a forever loop so it always sets the rotation of the camera