Repository: godotengine/godot
File: editor/settings/input_event_configuration_dialog.cpp (C++)

Code before:
#include "editor/themes/editor_scale.h"
#include "scene/gui/check_box.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/option_button.h"
#include "scene/gui/separator.h"
#include "scene/gui/tree.h"

void InputEventConfigurationDialog::_set_event(const Ref<InputEvent> &p_event, const Ref<InputEvent> &p_original_event, bool p_update_input_list_selection) {
	if (p_event.is_valid()) {
		event = p_event;
		original_event = p_original_event;

		// If the event is changed to something which is not the same as the listener,
		// clear out the event from the listener text box to avoid confusion.
		const Ref<InputEvent> listener_event = event_listener->get_event();
		if (listener_event.is_valid() && !listener_event->is_match(p_event)) {
			event_listener->clear_event();
		}

		// Update Label
		event_as_text->set_text(EventListenerLineEdit::get_event_text(event, true));

		bool exists = false;
		for (int i = 0; i < action_events.size(); i++) {
			Ref<InputEvent> ie = action_events[i];
			if (ie.is_null()) {
				continue;
			} else if (ie->is_match(p_event)) {
				exists = true;
				break;
			}
		}
		event_exists->set_visible(exists);
		get_ok_button()->set_disabled(exists);

		Ref<InputEventKey> k = p_event;
		Ref<InputEventMouseButton> mb = p_event;
		Ref<InputEventJoypadButton> joyb = p_event;
		Ref<InputEventJoypadMotion> joym = p_event;
		Ref<InputEventWithModifiers> mod = p_event;

		// Update option values and visibility
		bool show_mods = false;
		bool show_device = false;
		bool show_key = false;
		bool show_location = false;

		if (mod.is_valid()) {
			show_mods = true;
			mod_checkboxes[MOD_ALT]->set_pressed(mod->is_alt_pressed());

Review comment (suggestion):
```suggestion
		for (const Variant &v : action_events) {
			Ref<InputEvent> ie = v;
```
(not 100% it works like that though)

Code after:
#include "editor/themes/editor_scale.h"
#include "scene/gui/check_box.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/option_button.h"
#include "scene/gui/separator.h"
#include "scene/gui/tree.h"

void InputEventConfigurationDialog::_set_event(const Ref<InputEvent> &p_event, const Ref<InputEvent> &p_original_event, bool p_update_input_list_selection) {
	if (p_event.is_valid()) {
		event = p_event;
		original_event = p_original_event;

		// If the event is changed to something which is not the same as the listener,
		// clear out the event from the listener text box to avoid confusion.
		const Ref<InputEvent> listener_event = event_listener->get_event();
		if (listener_event.is_valid() && !listener_event->is_match(p_event)) {
			event_listener->clear_event();
		}

		// Update Label
		event_as_text->set_text(EventListenerLineEdit::get_event_text(event, true));

		bool exists = false;
		for (const Variant &v : action_events) {
			Ref<InputEvent> ie = v;
			if (ie.is_null()) {
				continue;
			} else if (ie->is_match(p_event)) {
				exists = true;
				break;
			}
		}
		event_exists->set_visible(exists);
		get_ok_button()->set_disabled(exists);

		Ref<InputEventKey> k = p_event;
		Ref<InputEventMouseButton> mb = p_event;
		Ref<InputEventJoypadButton> joyb = p_event;
		Ref<InputEventJoypadMotion> joym = p_event;
		Ref<InputEventWithModifiers> mod = p_event;

		// Update option values and visibility
		bool show_mods = false;
		bool show_device = false;
		bool show_key = false;
		bool show_location = false;

		if (mod.is_valid()) {
			show_mods = true;
			mod_checkboxes[MOD_ALT]->set_pressed(mod->is_alt_pressed());