The Godot Community Forums are back up and running! Please read the the announcement post for important information on what happened. Thanks!

The CollisionObject2D's mouse_entered signal cannot be triggered in editor

vmjcvvmjcv Posts: 45Member
edited September 14 in Programming

I have a scene that has a signal mouse_entered. When i move the mouse over the circle it will change color to red.
like this:

but when i add it to editor, it cannot be triggered in editor
like this:

this is my code for add view in godot editor

_graph_editor_view = preload("res://addons/event_chain/editor/view.tscn").instance()
#_graph_editor_view.undo_redo = get_undo_redo()
_panel_button = add_control_to_bottom_panel(_graph_editor_view, "Event Chain Graph Editor")
_panel_button.visible = true

I think the problem is godot editor's mouse_filter is stop or pass, so i cannot get the signal.
Of course this is just what I think, if there are other possible reasons, please let me know.

My question is how should I get this signal in editor.

i need your help please,thanks a lot.

In order to better illustrate the problem, I provide a demo as attach


  • TwistedTwiglegTwistedTwigleg Posts: 3,141Admin

    If you are okay with using physics to detect the mouse entering and exiting, you can use a StaticBody/RigidBody (set to static) and then check to see what collision objects are under the mouse using the intersect_point function. I made a really quick example using the test project and it seems to work okay. I've attached the project to this post if you want to take a look.

  • vmjcvvmjcv Posts: 45Member
    edited September 15

    Thanks your answer.
    i test it.everything is ok.

    And i change something
    1. change the node to area2d
    2. change the code var results = space_state.intersect_point(mouse_position,32,[],0x00000002,true,true);

    My reason is that your method may affect other collision, so I added a physics layer to these UI. Mouse events only triggered to these layers. It should be acceptable to occupy a physics layer in project.

    Thank you very much for your reply, this is a solution that can be used.

    Godot’s mouse signal and this are two logics,feel a little strange, and I hope it can be a unified notification event.

    So I will not close the question, if there are other different solutions

    But no matter what, thank you for the feasible solution

  • vmjcvvmjcv Posts: 45Member

    I change the gd script

    extends Node2D
    var hit_objects = []
    func _physics_process(delta):
        var space_rid = get_world_2d().space
        var space_state = Physics2DServer.space_get_direct_state(space_rid)
        var mouse_position = get_global_mouse_position()
        var not_in_objects = hit_objects.duplicate()
        hit_objects = []
        var results = space_state.intersect_point(mouse_position,32,[],524288,true,true)
        for result in results:
            if (hit_objects.has(result["collider"]) == false):
                if (result["collider"].has_signal("mouse_entered")):
            if (not_in_objects.has(result["collider"])):
        for not_in_object in not_in_objects:
            if (not_in_object.has_signal("mouse_exited")):

    the code is attach in a node. it will let all the node who is in Layer20 emit signal mouse_entered and mouse_exited. It's like retriggering the signal that was swallowed by the editor

    I think it can solve my problem.But it would be better if the signal could not be swallowed by the editor

    In short ,your answer is very good and very enlightening

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file