Skip to content

Commit

Permalink
Make Viewport::gui_get_focus_owner const
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronfranke committed Jun 2, 2023
1 parent d3e4db4 commit 8b42297
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/classes/Viewport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
Returns the drag data from the GUI, that was previously returned by [method Control._get_drag_data].
</description>
</method>
<method name="gui_get_focus_owner">
<method name="gui_get_focus_owner" qualifiers="const">
<return type="Control" />
<description>
Returns the [Control] having the focus within this viewport. If no [Control] has the focus, returns null.
Expand Down
8 changes: 8 additions & 0 deletions misc/extension_api_validation/4.0-stable.expected
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ should instead be used to justify these changes and describe how users should wo

========================================================================================================================

GH-77757
--------
Validate extension JSON: Error: Field 'classes/Viewport/methods/gui_get_focus_owner': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Hash changed for 'classes/Viewport/methods/gui_get_focus_owner', from 31757941 to A5E188F5. This means that the function has changed and no compatibility function was provided.

This method does not affect the state of Viewport so it should be const.


GH-74736
--------
Validate extension JSON: Error: Field 'classes/MenuBar/properties/start_index': type changed value in new API, from "bool" to "int".
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/spin_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void SpinBox::_line_edit_focus_enter() {

void SpinBox::_line_edit_focus_exit() {
// Discontinue because the focus_exit was caused by left-clicking the arrows.
Viewport *viewport = get_viewport();
const Viewport *viewport = get_viewport();
if (!viewport || viewport->gui_get_focus_owner() == get_line_edit()) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3156,7 +3156,7 @@ void Viewport::gui_release_focus() {
}
}

Control *Viewport::gui_get_focus_owner() {
Control *Viewport::gui_get_focus_owner() const {
ERR_READ_THREAD_GUARD_V(nullptr);
return gui.key_focus;
}
Expand Down
2 changes: 1 addition & 1 deletion scene/main/viewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ class Viewport : public Node {
int gui_get_canvas_sort_index();

void gui_release_focus();
Control *gui_get_focus_owner();
Control *gui_get_focus_owner() const;

PackedStringArray get_configuration_warnings() const override;

Expand Down

0 comments on commit 8b42297

Please sign in to comment.