Merge pull request #57517 from groud/viewport_expose_gui_focus
This commit is contained in:
commit
36880714e4
@ -107,6 +107,12 @@
|
|||||||
Returns the drag data from the GUI, that was previously returned by [method Control._get_drag_data].
|
Returns the drag data from the GUI, that was previously returned by [method Control._get_drag_data].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="gui_get_focus_owner">
|
||||||
|
<return type="Control" />
|
||||||
|
<description>
|
||||||
|
Returns the [Control] having the focus within this viewport. If no [Control] has the focus, returns null.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="gui_is_drag_successful" qualifiers="const">
|
<method name="gui_is_drag_successful" qualifiers="const">
|
||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<description>
|
<description>
|
||||||
@ -119,6 +125,12 @@
|
|||||||
Returns [code]true[/code] if the viewport is currently performing a drag operation.
|
Returns [code]true[/code] if the viewport is currently performing a drag operation.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="gui_release_focus">
|
||||||
|
<return type="void" />
|
||||||
|
<description>
|
||||||
|
Removes the focus from the currently focussed [Control] within this viewport. If no [Control] has the focus, does nothing.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="is_embedding_subwindows" qualifiers="const">
|
<method name="is_embedding_subwindows" qualifiers="const">
|
||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<description>
|
<description>
|
||||||
|
@ -2196,8 +2196,7 @@ void Control::release_focus() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
get_viewport()->_gui_remove_focus();
|
get_viewport()->gui_release_focus();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Control::is_top_level_control() const {
|
bool Control::is_top_level_control() const {
|
||||||
@ -2602,7 +2601,7 @@ Control::MouseFilter Control::get_mouse_filter() const {
|
|||||||
|
|
||||||
Control *Control::get_focus_owner() const {
|
Control *Control::get_focus_owner() const {
|
||||||
ERR_FAIL_COND_V(!is_inside_tree(), nullptr);
|
ERR_FAIL_COND_V(!is_inside_tree(), nullptr);
|
||||||
return get_viewport()->_gui_get_focus_owner();
|
return get_viewport()->gui_get_focus_owner();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Control::warp_mouse(const Point2 &p_to_pos) {
|
void Control::warp_mouse(const Point2 &p_to_pos) {
|
||||||
|
@ -2092,7 +2092,7 @@ void Viewport::_gui_hide_control(Control *p_control) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gui.key_focus == p_control) {
|
if (gui.key_focus == p_control) {
|
||||||
_gui_remove_focus();
|
gui_release_focus();
|
||||||
}
|
}
|
||||||
if (gui.mouse_over == p_control) {
|
if (gui.mouse_over == p_control) {
|
||||||
gui.mouse_over = nullptr;
|
gui.mouse_over = nullptr;
|
||||||
@ -2142,15 +2142,7 @@ Window *Viewport::get_base_window() const {
|
|||||||
}
|
}
|
||||||
void Viewport::_gui_remove_focus_for_window(Node *p_window) {
|
void Viewport::_gui_remove_focus_for_window(Node *p_window) {
|
||||||
if (get_base_window() == p_window) {
|
if (get_base_window() == p_window) {
|
||||||
_gui_remove_focus();
|
gui_release_focus();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Viewport::_gui_remove_focus() {
|
|
||||||
if (gui.key_focus) {
|
|
||||||
Node *f = gui.key_focus;
|
|
||||||
gui.key_focus = nullptr;
|
|
||||||
f->notification(Control::NOTIFICATION_FOCUS_EXIT, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2279,10 +2271,6 @@ void Viewport::_cleanup_mouseover_colliders(bool p_clean_all_frames, bool p_paus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Control *Viewport::_gui_get_focus_owner() {
|
|
||||||
return gui.key_focus;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Viewport::_gui_grab_click_focus(Control *p_control) {
|
void Viewport::_gui_grab_click_focus(Control *p_control) {
|
||||||
gui.mouse_click_grabber = p_control;
|
gui.mouse_click_grabber = p_control;
|
||||||
call_deferred(SNAME("_post_gui_grab_click_focus"));
|
call_deferred(SNAME("_post_gui_grab_click_focus"));
|
||||||
@ -2798,6 +2786,19 @@ int Viewport::gui_get_canvas_sort_index() {
|
|||||||
return gui.canvas_sort_index++;
|
return gui.canvas_sort_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Viewport::gui_release_focus() {
|
||||||
|
if (gui.key_focus) {
|
||||||
|
Control *f = gui.key_focus;
|
||||||
|
gui.key_focus = nullptr;
|
||||||
|
f->notification(Control::NOTIFICATION_FOCUS_EXIT, true);
|
||||||
|
f->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Control *Viewport::gui_get_focus_owner() {
|
||||||
|
return gui.key_focus;
|
||||||
|
}
|
||||||
|
|
||||||
void Viewport::set_msaa(MSAA p_msaa) {
|
void Viewport::set_msaa(MSAA p_msaa) {
|
||||||
ERR_FAIL_INDEX(p_msaa, MSAA_MAX);
|
ERR_FAIL_INDEX(p_msaa, MSAA_MAX);
|
||||||
if (msaa == p_msaa) {
|
if (msaa == p_msaa) {
|
||||||
@ -3591,6 +3592,9 @@ void Viewport::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("gui_is_dragging"), &Viewport::gui_is_dragging);
|
ClassDB::bind_method(D_METHOD("gui_is_dragging"), &Viewport::gui_is_dragging);
|
||||||
ClassDB::bind_method(D_METHOD("gui_is_drag_successful"), &Viewport::gui_is_drag_successful);
|
ClassDB::bind_method(D_METHOD("gui_is_drag_successful"), &Viewport::gui_is_drag_successful);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("gui_release_focus"), &Viewport::gui_release_focus);
|
||||||
|
ClassDB::bind_method(D_METHOD("gui_get_focus_owner"), &Viewport::gui_get_focus_owner);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_disable_input", "disable"), &Viewport::set_disable_input);
|
ClassDB::bind_method(D_METHOD("set_disable_input", "disable"), &Viewport::set_disable_input);
|
||||||
ClassDB::bind_method(D_METHOD("is_input_disabled"), &Viewport::is_input_disabled);
|
ClassDB::bind_method(D_METHOD("is_input_disabled"), &Viewport::is_input_disabled);
|
||||||
|
|
||||||
|
@ -411,7 +411,6 @@ private:
|
|||||||
Control *_gui_get_drag_preview();
|
Control *_gui_get_drag_preview();
|
||||||
|
|
||||||
void _gui_remove_focus_for_window(Node *p_window);
|
void _gui_remove_focus_for_window(Node *p_window);
|
||||||
void _gui_remove_focus();
|
|
||||||
void _gui_unfocus_control(Control *p_control);
|
void _gui_unfocus_control(Control *p_control);
|
||||||
bool _gui_control_has_focus(const Control *p_control);
|
bool _gui_control_has_focus(const Control *p_control);
|
||||||
void _gui_control_grab_focus(Control *p_control);
|
void _gui_control_grab_focus(Control *p_control);
|
||||||
@ -419,8 +418,6 @@ private:
|
|||||||
void _post_gui_grab_click_focus();
|
void _post_gui_grab_click_focus();
|
||||||
void _gui_accept_event();
|
void _gui_accept_event();
|
||||||
|
|
||||||
Control *_gui_get_focus_owner();
|
|
||||||
|
|
||||||
bool _gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check);
|
bool _gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check);
|
||||||
|
|
||||||
friend class AudioListener2D;
|
friend class AudioListener2D;
|
||||||
@ -559,6 +556,9 @@ public:
|
|||||||
void gui_reset_canvas_sort_index();
|
void gui_reset_canvas_sort_index();
|
||||||
int gui_get_canvas_sort_index();
|
int gui_get_canvas_sort_index();
|
||||||
|
|
||||||
|
void gui_release_focus();
|
||||||
|
Control *gui_get_focus_owner();
|
||||||
|
|
||||||
TypedArray<String> get_configuration_warnings() const override;
|
TypedArray<String> get_configuration_warnings() const override;
|
||||||
|
|
||||||
void set_debug_draw(DebugDraw p_debug_draw);
|
void set_debug_draw(DebugDraw p_debug_draw);
|
||||||
|
Loading…
Reference in New Issue
Block a user