summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-02-03 13:35:19 +0100
committerGitHub <noreply@github.com>2022-02-03 13:35:19 +0100
commit7f93eb34cf4b4e900aa9ba185b009fcb409d5d1c (patch)
tree3d31386b4c8200d9882b639b98728588802e0b96
parente165f18ae532ddf118b19bdd439f4ac6c226903a (diff)
parent73e784de1e95cfdf775e00e608114f5295813060 (diff)
Merge pull request #57581 from groud/remove_get_fowus_owner
-rw-r--r--doc/classes/Control.xml6
-rw-r--r--editor/animation_track_editor.cpp2
-rw-r--r--editor/code_editor.cpp4
-rw-r--r--editor/editor_help.cpp2
-rw-r--r--editor/editor_inspector.cpp2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp2
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp2
-rw-r--r--editor/plugins/theme_editor_plugin.cpp2
-rw-r--r--editor/rename_dialog.cpp4
-rw-r--r--editor/scene_tree_dock.cpp2
-rw-r--r--scene/gui/base_button.cpp2
-rw-r--r--scene/gui/control.cpp6
-rw-r--r--scene/gui/control.h2
13 files changed, 12 insertions, 26 deletions
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index d5551e1e04..b6c2dac33c 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -380,12 +380,6 @@
Returns the focus neighbor for the specified [enum Side]. A getter method for [member focus_neighbor_bottom], [member focus_neighbor_left], [member focus_neighbor_right] and [member focus_neighbor_top].
</description>
</method>
- <method name="get_focus_owner" qualifiers="const">
- <return type="Control" />
- <description>
- Returns the control that has the keyboard focus or [code]null[/code] if none.
- </description>
- </method>
<method name="get_global_rect" qualifiers="const">
<return type="Rect2" />
<description>
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 433866602b..e36d0b846b 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -3481,7 +3481,7 @@ void AnimationTrackEditor::_track_remove_request(int p_track) {
void AnimationTrackEditor::_track_grab_focus(int p_track) {
// Don't steal focus if not working with the track editor.
- if (Object::cast_to<AnimationTrackEdit>(get_focus_owner())) {
+ if (Object::cast_to<AnimationTrackEdit>(get_viewport()->gui_get_focus_owner())) {
track_edits[p_track]->grab_focus();
}
}
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 0a269d960e..967f7e0d1f 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -122,7 +122,7 @@ void FindReplaceBar::unhandled_input(const Ref<InputEvent> &p_event) {
return;
}
- Control *focus_owner = get_focus_owner();
+ Control *focus_owner = get_viewport()->gui_get_focus_owner();
if (text_editor->has_focus() || (focus_owner && vbc_lineedit->is_ancestor_of(focus_owner))) {
bool accepted = true;
@@ -724,7 +724,7 @@ void CodeTextEditor::input(const Ref<InputEvent> &event) {
}
if (!text_editor->has_focus()) {
- if ((find_replace_bar != nullptr && find_replace_bar->is_visible()) && (find_replace_bar->has_focus() || find_replace_bar->is_ancestor_of(get_focus_owner()))) {
+ if ((find_replace_bar != nullptr && find_replace_bar->is_visible()) && (find_replace_bar->has_focus() || find_replace_bar->is_ancestor_of(get_viewport()->gui_get_focus_owner()))) {
if (ED_IS_SHORTCUT("script_text_editor/find_next", key_event)) {
find_replace_bar->search_next();
accept_event();
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 946fe6d893..bb76af8f9b 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -2128,7 +2128,7 @@ void FindBar::unhandled_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
- if (k->is_pressed() && (rich_text_label->has_focus() || is_ancestor_of(get_focus_owner()))) {
+ if (k->is_pressed() && (rich_text_label->has_focus() || is_ancestor_of(get_viewport()->gui_get_focus_owner()))) {
bool accepted = true;
switch (k->get_keycode()) {
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 0d68051125..6f7508b10b 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -2299,7 +2299,7 @@ void EditorInspector::update_tree() {
if (property_focusable != -1) {
//check focusable is really focusable
bool restore_focus = false;
- Control *focused = get_focus_owner();
+ Control *focused = get_viewport() ? get_viewport()->gui_get_focus_owner() : nullptr;
if (focused) {
Node *parent = focused->get_parent();
while (parent) {
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index dff01cbf05..d496804bf2 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -2507,7 +2507,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
_update_cursor();
// Grab focus
- if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) {
+ if (!viewport->has_focus() && (!get_viewport()->gui_get_focus_owner() || !get_viewport()->gui_get_focus_owner()->is_text_field())) {
viewport->call_deferred(SNAME("grab_focus"));
}
}
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 4610171d68..0c0188e8d1 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -1203,7 +1203,7 @@ Transform3D Node3DEditorViewport::_compute_transform(TransformMode p_mode, const
}
void Node3DEditorViewport::_surface_mouse_enter() {
- if (!surface->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) {
+ if (!surface->has_focus() && (!get_viewport()->gui_get_focus_owner() || !get_viewport()->gui_get_focus_owner()->is_text_field())) {
surface->grab_focus();
}
}
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index bc2739bdac..aaa09237cf 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -2226,7 +2226,7 @@ void ThemeTypeEditor::_update_type_list() {
}
updating = true;
- Control *focused = get_focus_owner();
+ Control *focused = get_viewport()->gui_get_focus_owner();
if (focused) {
if (focusables.has(focused)) {
// If focus is currently on one of the internal property editors, don't update.
diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp
index 92dcd53830..c6a4c0d86a 100644
--- a/editor/rename_dialog.cpp
+++ b/editor/rename_dialog.cpp
@@ -337,7 +337,7 @@ void RenameDialog::_bind_methods() {
}
void RenameDialog::_update_substitute() {
- LineEdit *focus_owner_line_edit = Object::cast_to<LineEdit>(scene_tree_editor->get_focus_owner());
+ LineEdit *focus_owner_line_edit = Object::cast_to<LineEdit>(scene_tree_editor->get_viewport()->gui_get_focus_owner());
bool is_main_field = _is_main_field(focus_owner_line_edit);
but_insert_name->set_disabled(!is_main_field);
@@ -632,7 +632,7 @@ bool RenameDialog::_is_main_field(LineEdit *line_edit) {
}
void RenameDialog::_insert_text(String text) {
- LineEdit *focus_owner = Object::cast_to<LineEdit>(scene_tree_editor->get_focus_owner());
+ LineEdit *focus_owner = Object::cast_to<LineEdit>(scene_tree_editor->get_viewport()->gui_get_focus_owner());
if (_is_main_field(focus_owner)) {
focus_owner->selection_delete();
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 30ea1bcbb9..9b18d3a491 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -78,7 +78,7 @@ void SceneTreeDock::input(const Ref<InputEvent> &p_event) {
void SceneTreeDock::unhandled_key_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
- if (get_focus_owner() && get_focus_owner()->is_text_field()) {
+ if (get_viewport()->gui_get_focus_owner() && get_viewport()->gui_get_focus_owner()->is_text_field()) {
return;
}
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index ec451b07cf..da2ef6c5ec 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -403,7 +403,7 @@ bool BaseButton::_is_focus_owner_in_shorcut_context() const {
}
Node *ctx_node = get_shortcut_context();
- Control *vp_focus = get_focus_owner();
+ Control *vp_focus = get_viewport() ? get_viewport()->gui_get_focus_owner() : nullptr;
// If the context is valid and the viewport focus is valid, check if the context is the focus or is a parent of it.
return ctx_node && vp_focus && (ctx_node == vp_focus || ctx_node->is_ancestor_of(vp_focus));
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index b32b32e3b9..fdae8e2f1f 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2599,11 +2599,6 @@ Control::MouseFilter Control::get_mouse_filter() const {
return data.mouse_filter;
}
-Control *Control::get_focus_owner() const {
- ERR_FAIL_COND_V(!is_inside_tree(), nullptr);
- return get_viewport()->gui_get_focus_owner();
-}
-
void Control::warp_mouse(const Point2 &p_to_pos) {
ERR_FAIL_COND(!is_inside_tree());
get_viewport()->warp_mouse(get_global_transform().xform(p_to_pos));
@@ -2893,7 +2888,6 @@ void Control::_bind_methods() {
ClassDB::bind_method(D_METHOD("release_focus"), &Control::release_focus);
ClassDB::bind_method(D_METHOD("find_prev_valid_focus"), &Control::find_prev_valid_focus);
ClassDB::bind_method(D_METHOD("find_next_valid_focus"), &Control::find_next_valid_focus);
- ClassDB::bind_method(D_METHOD("get_focus_owner"), &Control::get_focus_owner);
ClassDB::bind_method(D_METHOD("set_h_size_flags", "flags"), &Control::set_h_size_flags);
ClassDB::bind_method(D_METHOD("get_h_size_flags"), &Control::get_h_size_flags);
diff --git a/scene/gui/control.h b/scene/gui/control.h
index bf79f790e7..962135280f 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -462,8 +462,6 @@ public:
void set_focus_previous(const NodePath &p_prev);
NodePath get_focus_previous() const;
- Control *get_focus_owner() const;
-
void set_mouse_filter(MouseFilter p_filter);
MouseFilter get_mouse_filter() const;