+2 votes

I have the following node tree where my spatial is a packed scene. node tree

I have static bodies in my scene with the following code.

func _input_event(camera, event, click_position, click_normal, shape_idx):
    if event is InputEventMouseButton and event.button_index == BUTTON_LEFT:
        print("clicked %s" % self)

In order for this to work the mouse input must be unhandled. By default the HSplitContainer will handle any mouse button inputs. I can set the mouse filter to ignore on the HSplitContainer but then I can no longer resize the HSplitContainer since I can't click on the grabber.

If there's a way to explicitly set an event as unhandled I can't find it.

How can I get unhandled mouse inputs inside of my spatial without ignoring mouse events for HSplitContainer?

Godot version 3.2.2
in Engine by (63 points)

Hi, did you found a solution?

I came up with something that worked at least for my use case. In the left pane of my split view I had a HBoxContainer, in the right I had the viewport.

I added some code to change mousefilter of the splitview to MOUSEFILTER_IGNORE when the mouse had a greater x value than the left pane of the splitview.

My splitview has the following script attached.

var _divider_offset = 10

func _input(event) -> void:
    if event.position.x < $HBoxContainer.rect_size.x + _divider_offset:
        mouse_filter = MOUSE_FILTER_PASS
    else:
        mouse_filter = MOUSE_FILTER_IGNORE

I was never very happy with this but it works.

1 Answer

+1 vote
Best answer

There is a SceneTree.set_input_as_handled() but no reverse function.

If you override _input(event), it should not matter whether or not the input is marked as handled, only for _unhandled_input(event) or _gui_input(event).

If you really need to, you could set up a "bridge". Detect the input in a script inside your Node named Node, then transfer the information down to your Spatial.

by (2,630 points)
selected by

Hi, can you show how to do that?

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 Frequently asked questions and 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 [email protected] with your username.