summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_properties.cpp2
-rw-r--r--editor/event_listener_line_edit.cpp13
-rw-r--r--editor/event_listener_line_edit.h4
-rw-r--r--editor/input_event_configuration_dialog.cpp4
4 files changed, 19 insertions, 4 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 332e47dc52..899fa69be1 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -90,7 +90,9 @@ void EditorPropertyText::update_property() {
String s = get_edited_object()->get(get_edited_property());
updating = true;
if (text->get_text() != s) {
+ int caret = text->get_caret_column();
text->set_text(s);
+ text->set_caret_column(caret);
}
text->set_editable(!is_read_only());
updating = false;
diff --git a/editor/event_listener_line_edit.cpp b/editor/event_listener_line_edit.cpp
index 14e482432a..e4c35a5b81 100644
--- a/editor/event_listener_line_edit.cpp
+++ b/editor/event_listener_line_edit.cpp
@@ -59,8 +59,9 @@ void EventListenerLineEdit::gui_input(const Ref<InputEvent> &p_event) {
// First event will be an event which is used to focus this control - i.e. a mouse click, or a tab press.
// Ignore the first one so that clicking into the LineEdit does not override the current event.
// Ignore is reset to true when the control is unfocused.
- if (ignore) {
- ignore = false;
+ // This class also specially handles grab_focus() calls.
+ if (ignore_next_event) {
+ ignore_next_event = false;
return;
}
@@ -85,7 +86,7 @@ void EventListenerLineEdit::_on_focus() {
}
void EventListenerLineEdit::_on_unfocus() {
- ignore = true;
+ ignore_next_event = true;
set_placeholder(TTR("Filter by event..."));
}
@@ -109,6 +110,12 @@ int EventListenerLineEdit::get_allowed_input_types() const {
return allowed_input_types;
}
+void EventListenerLineEdit::grab_focus() {
+ // If we grab focus through code, we don't need to ignore the first event!
+ ignore_next_event = false;
+ Control::grab_focus();
+}
+
void EventListenerLineEdit::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
diff --git a/editor/event_listener_line_edit.h b/editor/event_listener_line_edit.h
index 5b415e8a2d..c4cd5e4511 100644
--- a/editor/event_listener_line_edit.h
+++ b/editor/event_listener_line_edit.h
@@ -44,7 +44,7 @@ class EventListenerLineEdit : public LineEdit {
GDCLASS(EventListenerLineEdit, LineEdit)
int allowed_input_types = INPUT_KEY | INPUT_MOUSE_BUTTON | INPUT_JOY_BUTTON | INPUT_JOY_MOTION;
- bool ignore = true;
+ bool ignore_next_event = true;
bool share_keycodes = false;
Ref<InputEvent> event;
@@ -67,6 +67,8 @@ public:
void set_allowed_input_types(int input_types);
int get_allowed_input_types() const;
+ void grab_focus();
+
public:
EventListenerLineEdit();
};
diff --git a/editor/input_event_configuration_dialog.cpp b/editor/input_event_configuration_dialog.cpp
index ed9a5898fb..c577c61db7 100644
--- a/editor/input_event_configuration_dialog.cpp
+++ b/editor/input_event_configuration_dialog.cpp
@@ -533,6 +533,10 @@ String InputEventConfigurationDialog::_get_device_string(int p_device) const {
void InputEventConfigurationDialog::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ event_listener->grab_focus();
+ } break;
+
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
input_list_search->set_right_icon(input_list_search->get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));