Exposes gui_release_focus and gui_get_focus_owner to Viewport
This commit is contained in:
parent
473f681651
commit
3521eecb4c
4 changed files with 35 additions and 20 deletions
|
@ -107,6 +107,12 @@
|
|||
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">
|
||||
<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">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
|
@ -119,6 +125,12 @@
|
|||
Returns [code]true[/code] if the viewport is currently performing a drag operation.
|
||||
</description>
|
||||
</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">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
|
|
|
@ -2196,8 +2196,7 @@ void Control::release_focus() {
|
|||
return;
|
||||
}
|
||||
|
||||
get_viewport()->_gui_remove_focus();
|
||||
update();
|
||||
get_viewport()->gui_release_focus();
|
||||
}
|
||||
|
||||
bool Control::is_top_level_control() const {
|
||||
|
@ -2602,7 +2601,7 @@ Control::MouseFilter Control::get_mouse_filter() const {
|
|||
|
||||
Control *Control::get_focus_owner() const {
|
||||
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) {
|
||||
|
|
|
@ -2098,7 +2098,7 @@ void Viewport::_gui_hide_control(Control *p_control) {
|
|||
}
|
||||
|
||||
if (gui.key_focus == p_control) {
|
||||
_gui_remove_focus();
|
||||
gui_release_focus();
|
||||
}
|
||||
if (gui.mouse_over == p_control) {
|
||||
gui.mouse_over = nullptr;
|
||||
|
@ -2148,15 +2148,7 @@ Window *Viewport::get_base_window() const {
|
|||
}
|
||||
void Viewport::_gui_remove_focus_for_window(Node *p_window) {
|
||||
if (get_base_window() == p_window) {
|
||||
_gui_remove_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);
|
||||
gui_release_focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2278,10 +2270,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) {
|
||||
gui.mouse_click_grabber = p_control;
|
||||
call_deferred(SNAME("_post_gui_grab_click_focus"));
|
||||
|
@ -2797,6 +2785,19 @@ int Viewport::gui_get_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) {
|
||||
ERR_FAIL_INDEX(p_msaa, MSAA_MAX);
|
||||
if (msaa == p_msaa) {
|
||||
|
@ -3590,6 +3591,9 @@ void Viewport::_bind_methods() {
|
|||
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_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("is_input_disabled"), &Viewport::is_input_disabled);
|
||||
|
||||
|
|
|
@ -410,7 +410,6 @@ private:
|
|||
Control *_gui_get_drag_preview();
|
||||
|
||||
void _gui_remove_focus_for_window(Node *p_window);
|
||||
void _gui_remove_focus();
|
||||
void _gui_unfocus_control(Control *p_control);
|
||||
bool _gui_control_has_focus(const Control *p_control);
|
||||
void _gui_control_grab_focus(Control *p_control);
|
||||
|
@ -418,8 +417,6 @@ private:
|
|||
void _post_gui_grab_click_focus();
|
||||
void _gui_accept_event();
|
||||
|
||||
Control *_gui_get_focus_owner();
|
||||
|
||||
bool _gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check);
|
||||
|
||||
friend class AudioListener2D;
|
||||
|
@ -557,6 +554,9 @@ public:
|
|||
void gui_reset_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;
|
||||
|
||||
void set_debug_draw(DebugDraw p_debug_draw);
|
||||
|
|
Loading…
Reference in a new issue