Godot: mouse enter signal does not work when the LMB is pressed

Created on 26 Oct 2018  路  3Comments  路  Source: godotengine/godot

when I tried to implement a bag with drag and drop function, I found that when I pressed the LMB in the control node. the mouse enter and exited signal does not work. I also found there was a similiar issue right here #6362 which was closed a long time ago.

public override void _Ready()
{
Control cell = (Control)getNode("Cell");
cell.Connect("mouse_entered", this, "onMouseEntered");
cell.Connect("mouse_exited", this, "onMouseExited");
}
public void onMouseEntered(){
GD.Print("on mouse enter");
}

public void onMouseExited(){
GD.Print("on mouse exit");
}

public override void _Input(InputEvent @event){
if (@event.IsActionPressed("mouse_left_button")){
GD.Print("press LMB"):
}
}

enhancement core input

Most helpful comment

I just struggled with this too.
maybe as proposed in #6362, ondragout, ondragover could be a nice solution.

All 3 comments

I just struggled with this too.
maybe as proposed in #6362, ondragout, ondragover could be a nice solution.

Can confirm it on my system (windows)
same for mouse_exited and for any mouse button (LMB, MMB, RMB...).

My problem is I need to know if the mouse is on the control.
And I thought I can use mouse_entered and mouse_exited signals.
But the signals aren't triggered immediately when any button of the mouse is pressed (they Are emitted but only when mouse is released in this case)

So do I need to reinvent the wheel, creating my_mouse_entered/my_mouse_exited signals, that are fired immediately in any case?

Imo this is unlogical and unexpected behavior and I imagine that a huge number of newbies can encounter this implicit behavior and spend time looking for the reason why their code is not working.

is this actually possible without using drag-events?

Was this page helpful?
0 / 5 - 0 ratings