Drop mouseover when mouse not in the window
Not that this is critical, but it makes behavior of GUI and 2D/3D picking consistent among them. This also contributes to dropping GUI focus when the mouse leaves the window (in addition to when it loses focus).
This commit is contained in:
parent
805eec7643
commit
5b00cd89d3
|
@ -659,7 +659,11 @@ void Viewport::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
case SceneTree::NOTIFICATION_WM_MOUSE_EXIT:
|
||||||
case SceneTree::NOTIFICATION_WM_FOCUS_OUT: {
|
case SceneTree::NOTIFICATION_WM_FOCUS_OUT: {
|
||||||
|
|
||||||
|
_drop_physics_mouseover();
|
||||||
|
|
||||||
if (gui.mouse_focus) {
|
if (gui.mouse_focus) {
|
||||||
//if mouse is being pressed, send a release event
|
//if mouse is being pressed, send a release event
|
||||||
_drop_mouse_focus();
|
_drop_mouse_focus();
|
||||||
|
@ -2561,6 +2565,31 @@ void Viewport::_drop_mouse_focus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Viewport::_drop_physics_mouseover() {
|
||||||
|
|
||||||
|
physics_has_last_mousepos = false;
|
||||||
|
|
||||||
|
while (physics_2d_mouseover.size()) {
|
||||||
|
Object *o = ObjectDB::get_instance(physics_2d_mouseover.front()->key());
|
||||||
|
if (o) {
|
||||||
|
CollisionObject2D *co = Object::cast_to<CollisionObject2D>(o);
|
||||||
|
co->_mouse_exit();
|
||||||
|
}
|
||||||
|
physics_2d_mouseover.erase(physics_2d_mouseover.front());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _3D_DISABLED
|
||||||
|
if (physics_object_over) {
|
||||||
|
CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(physics_object_over));
|
||||||
|
if (co) {
|
||||||
|
co->_mouse_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
physics_object_over = physics_object_capture = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
List<Control *>::Element *Viewport::_gui_show_modal(Control *p_control) {
|
List<Control *>::Element *Viewport::_gui_show_modal(Control *p_control) {
|
||||||
|
|
||||||
gui.modal_stack.push_back(p_control);
|
gui.modal_stack.push_back(p_control);
|
||||||
|
|
|
@ -383,6 +383,7 @@ private:
|
||||||
void _canvas_layer_remove(CanvasLayer *p_canvas_layer);
|
void _canvas_layer_remove(CanvasLayer *p_canvas_layer);
|
||||||
|
|
||||||
void _drop_mouse_focus();
|
void _drop_mouse_focus();
|
||||||
|
void _drop_physics_mouseover();
|
||||||
|
|
||||||
void _update_canvas_items(Node *p_node);
|
void _update_canvas_items(Node *p_node);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue