浏览代码

Fix scrollwheel triggering focus change

Clicking or using the scrollwheel outside of the focused control triggers a focus change. This makes sense for mouse clicks, but scrollwheeling outside the focuses control does not. This PR ignores scrollwheeling outside of the focused control.
Emmanuel Barroga 6 年之前
父节点
当前提交
b8007b3947
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      scene/main/viewport.cpp

+ 6 - 0
scene/main/viewport.cpp

@@ -1742,6 +1742,12 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
 							return; // no one gets the event if exclusive NO ONE
 						}
 
+						if (mb->get_button_index() == BUTTON_WHEEL_UP || mb->get_button_index() == BUTTON_WHEEL_DOWN || mb->get_button_index() == BUTTON_WHEEL_LEFT || mb->get_button_index() == BUTTON_WHEEL_RIGHT) {
+							//cancel scroll wheel events, only clicks should trigger focus changes.
+							set_input_as_handled();
+							return;
+						}
+
 						top->notification(Control::NOTIFICATION_MODAL_CLOSE);
 						top->_modal_stack_remove();
 						top->hide();