MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / push_input

Method push_input

scene/main/viewport.cpp:3407–3473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3405}
3406
3407void Viewport::push_input(const Ref<InputEvent> &p_event, bool p_local_coords) {
3408 ERR_MAIN_THREAD_GUARD;
3409 ERR_FAIL_COND(!is_inside_tree());
3410 ERR_FAIL_COND(p_event.is_null());
3411
3412 if (disable_input || disable_input_override) {
3413 return;
3414 }
3415
3416 if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this)) {
3417 return;
3418 }
3419
3420 local_input_handled = false;
3421 if (!handle_input_locally) {
3422 Viewport *vp = this;
3423 while (true) {
3424 if (Object::cast_to<Window>(vp) || !vp->get_parent()) {
3425 break;
3426 }
3427 vp = vp->get_parent()->get_viewport();
3428 }
3429 vp->local_input_handled = false;
3430 }
3431
3432 Ref<InputEvent> ev;
3433 if (!p_local_coords) {
3434 ev = _make_input_local(p_event);
3435 } else {
3436 ev = p_event;
3437 }
3438
3439 Ref<InputEventMouse> me = ev;
3440 if (me.is_valid()) {
3441 gui.last_mouse_pos = me->get_position();
3442
3443 _update_mouse_over();
3444 }
3445
3446 if (is_embedding_subwindows() && _sub_windows_forward_input(ev)) {
3447 set_input_as_handled();
3448 return;
3449 }
3450
3451 if (!_can_consume_input_events()) {
3452 return;
3453 }
3454
3455 if (!is_input_handled()) {
3456 ERR_FAIL_COND(!is_inside_tree());
3457 get_tree()->_call_input_pause(input_group, SceneTree::CALL_INPUT_TYPE_INPUT, ev, this); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input
3458 }
3459
3460 if (!is_input_handled()) {
3461 ERR_FAIL_COND(!is_inside_tree());
3462 _gui_input_event(ev);
3463 } else {
3464 // Cleanup internal GUI state after accepting event during _input().

Callers 7

_root_window_inputMethod · 0.80
_pressMethod · 0.80
_releaseMethod · 0.80
_target_gui_inputMethod · 0.80
shortcut_inputMethod · 0.80
test_viewport.hFile · 0.80

Calls 9

is_ancestor_ofMethod · 0.80
_call_input_pauseMethod · 0.80
is_nullMethod · 0.45
is_editor_hintMethod · 0.45
get_edited_scene_rootMethod · 0.45
get_parentMethod · 0.45
get_viewportMethod · 0.45
is_validMethod · 0.45
get_positionMethod · 0.45

Tested by

no test coverage detected