Godot: "mouse_entered" and "mouse_exited" signals are broken while holding down a mouse button

Created on 10 Aug 2018  ·  5Comments  ·  Source: godotengine/godot

Godot version:
fbb5ca4

OS/device including version:
Linux Manjaro

Issue description:
The "mouse_entered" and "mouse_exited" signals of control nodes don't get fired while holding any mouse button down when the click (any mouse button down) started on a control that does not ignore the mouse.

it's actually because in viewport.cpp in line 1843 to 1850 "over" get's set to the mouse_focus

if (gui.mouse_focus) {
    over = gui.mouse_focus;
    //recompute focus_inv_xform again here
} else {
    over = _gui_find_control(mpos);
}

and shortly after ( line 1884 to 1893 ) the mouse_exited and mouse_entered signals get not fired because the gui.mouse_focus and the gui.mouse_over are the same

if (over != gui.mouse_over) {

    if (gui.mouse_over)
        gui.mouse_over->notification(Control::NOTIFICATION_MOUSE_EXIT);

    _gui_cancel_tooltip();

    if (over)
        over->notification(Control::NOTIFICATION_MOUSE_ENTER);
}

This may be a desired behavior, for a lot of cases.
But there are also cases where it is very useful to send those signals. (I'll update this post soon to show such a case)

Steps to reproduce:

  1. Connect the "mouse_entered" or "mouse_exited" signal of any control node
  2. add another control node, that does not ignore the mouse
  3. start your drag on the control element of point 2 and drag over the control element from point 1
  4. notice that no "mouse_entered" and no "mouse_exited" signals get fired
bug confirmed gui input

All 5 comments

Confirmed on my master build too. Note: if you set mouse filter to "ignore" on the parent control the color rectangle signals works as expected.

linked to #23296

Note from #32727, this does also happen for is_hovered()

Godot版本:
fbb5ca4

操作系统/设备,包括版本:
Linux Manjaro

问题描述:
当在不忽略鼠标的控件上单击(按下任何鼠标按钮)时,按住任意鼠标按钮时,不会触发控制节点的“ mouse_entered”和“ mouse_exited”信号。

实际上是因为在1843至1850行的viewport.cpp中,“ over”被设置为mouse_focus

if (gui.mouse_focus) {
  over = gui.mouse_focus;
  //recompute focus_inv_xform again here
} else {
  over = _gui_find_control(mpos);
}

并且在之后(第1884至1893行)不久,由于gui.mouse_focus和gui.mouse_over相同,因此未触发mouse_exited和mouse_entered信号

if (over != gui.mouse_over) {

  if (gui.mouse_over)
      gui.mouse_over->notification(Control::NOTIFICATION_MOUSE_EXIT);

  _gui_cancel_tooltip();

  if (over)
      over->notification(Control::NOTIFICATION_MOUSE_ENTER);
}

在很多情况下,这可能是理想的行为。
但是在某些情况下,发送这些信号非常有用。(我将尽快更新此帖子以显示这种情况)

重现步骤:

  1. 连接任何控制节点的“ mouse_entered”或“ mouse_exited”信号
  2. 添加另一个不忽略鼠标的控制节点
  3. 在点2的控件元素上开始拖动,然后从点1的控件元素上拖动
  4. 请注意,没有触发“ mouse_entered”和“ mouse_exited”信号

how solve it...cry... #35262

Still an issue in Godot 3.2.2beta ed27b7e6b973eb6be6fdac4439e99a1907b9cb58

Was this page helpful?
0 / 5 - 0 ratings