mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
[GUI] Fix an issue where setting a control's recursive mode to disabled does not work on ready.
This commit is contained in:
parent
2303ce843a
commit
04608fae4a
2 changed files with 24 additions and 14 deletions
|
|
@ -1880,16 +1880,20 @@ void Control::set_mouse_recursive_behavior(RecursiveBehavior p_recursive_mouse_b
|
||||||
if (data.mouse_recursive_behavior == p_recursive_mouse_behavior) {
|
if (data.mouse_recursive_behavior == p_recursive_mouse_behavior) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_set_mouse_recursive_behavior_ignore_cache(p_recursive_mouse_behavior);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Control::_set_mouse_recursive_behavior_ignore_cache(RecursiveBehavior p_recursive_mouse_behavior) {
|
||||||
data.mouse_recursive_behavior = p_recursive_mouse_behavior;
|
data.mouse_recursive_behavior = p_recursive_mouse_behavior;
|
||||||
if (p_recursive_mouse_behavior == RECURSIVE_BEHAVIOR_INHERITED) {
|
if (p_recursive_mouse_behavior == RECURSIVE_BEHAVIOR_INHERITED) {
|
||||||
Control *parent = get_parent_control();
|
Control *parent = get_parent_control();
|
||||||
if (parent) {
|
if (parent) {
|
||||||
_apply_mouse_behavior_recursively(parent->data.parent_mouse_recursive_behavior, false);
|
_propagate_mouse_behavior_recursively(parent->data.parent_mouse_recursive_behavior, false);
|
||||||
} else {
|
} else {
|
||||||
_apply_mouse_behavior_recursively(RECURSIVE_BEHAVIOR_ENABLED, false);
|
_propagate_mouse_behavior_recursively(RECURSIVE_BEHAVIOR_ENABLED, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_apply_mouse_behavior_recursively(p_recursive_mouse_behavior, false);
|
_propagate_mouse_behavior_recursively(p_recursive_mouse_behavior, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_viewport()) {
|
if (get_viewport()) {
|
||||||
|
|
@ -2064,16 +2068,20 @@ void Control::set_focus_recursive_behavior(RecursiveBehavior p_recursive_focus_b
|
||||||
if (data.focus_recursive_behavior == p_recursive_focus_behavior) {
|
if (data.focus_recursive_behavior == p_recursive_focus_behavior) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_set_focus_recursive_behavior_ignore_cache(p_recursive_focus_behavior);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Control::_set_focus_recursive_behavior_ignore_cache(RecursiveBehavior p_recursive_focus_behavior) {
|
||||||
data.focus_recursive_behavior = p_recursive_focus_behavior;
|
data.focus_recursive_behavior = p_recursive_focus_behavior;
|
||||||
if (p_recursive_focus_behavior == RECURSIVE_BEHAVIOR_INHERITED) {
|
if (p_recursive_focus_behavior == RECURSIVE_BEHAVIOR_INHERITED) {
|
||||||
Control *parent = get_parent_control();
|
Control *parent = get_parent_control();
|
||||||
if (parent) {
|
if (parent) {
|
||||||
_apply_focus_behavior_recursively(parent->data.parent_focus_recursive_behavior, false);
|
_propagate_focus_behavior_recursively(parent->data.parent_focus_recursive_behavior, false);
|
||||||
} else {
|
} else {
|
||||||
_apply_focus_behavior_recursively(RECURSIVE_BEHAVIOR_ENABLED, false);
|
_propagate_focus_behavior_recursively(RECURSIVE_BEHAVIOR_ENABLED, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_apply_focus_behavior_recursively(p_recursive_focus_behavior, false);
|
_propagate_focus_behavior_recursively(p_recursive_focus_behavior, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2449,7 +2457,7 @@ bool Control::_is_focus_disabled_recursively() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Control::_apply_focus_behavior_recursively(RecursiveBehavior p_focus_recursive_behavior, bool p_skip_non_inherited) {
|
void Control::_propagate_focus_behavior_recursively(RecursiveBehavior p_focus_recursive_behavior, bool p_skip_non_inherited) {
|
||||||
if (is_inside_tree() && (data.focus_recursive_behavior == RECURSIVE_BEHAVIOR_DISABLED || (data.focus_recursive_behavior == RECURSIVE_BEHAVIOR_INHERITED && p_focus_recursive_behavior == RECURSIVE_BEHAVIOR_DISABLED)) && has_focus()) {
|
if (is_inside_tree() && (data.focus_recursive_behavior == RECURSIVE_BEHAVIOR_DISABLED || (data.focus_recursive_behavior == RECURSIVE_BEHAVIOR_INHERITED && p_focus_recursive_behavior == RECURSIVE_BEHAVIOR_DISABLED)) && has_focus()) {
|
||||||
release_focus();
|
release_focus();
|
||||||
}
|
}
|
||||||
|
|
@ -2463,7 +2471,7 @@ void Control::_apply_focus_behavior_recursively(RecursiveBehavior p_focus_recurs
|
||||||
for (int i = 0; i < get_child_count(); i++) {
|
for (int i = 0; i < get_child_count(); i++) {
|
||||||
Control *control = Object::cast_to<Control>(get_child(i));
|
Control *control = Object::cast_to<Control>(get_child(i));
|
||||||
if (control) {
|
if (control) {
|
||||||
control->_apply_focus_behavior_recursively(p_focus_recursive_behavior, true);
|
control->_propagate_focus_behavior_recursively(p_focus_recursive_behavior, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2480,7 +2488,7 @@ bool Control::_is_parent_mouse_disabled() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Control::_apply_mouse_behavior_recursively(RecursiveBehavior p_mouse_recursive_behavior, bool p_skip_non_inherited) {
|
void Control::_propagate_mouse_behavior_recursively(RecursiveBehavior p_mouse_recursive_behavior, bool p_skip_non_inherited) {
|
||||||
if (p_skip_non_inherited && data.mouse_recursive_behavior != RECURSIVE_BEHAVIOR_INHERITED) {
|
if (p_skip_non_inherited && data.mouse_recursive_behavior != RECURSIVE_BEHAVIOR_INHERITED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -2490,7 +2498,7 @@ void Control::_apply_mouse_behavior_recursively(RecursiveBehavior p_mouse_recurs
|
||||||
for (int i = 0; i < get_child_count(); i++) {
|
for (int i = 0; i < get_child_count(); i++) {
|
||||||
Control *control = Object::cast_to<Control>(get_child(i));
|
Control *control = Object::cast_to<Control>(get_child(i));
|
||||||
if (control) {
|
if (control) {
|
||||||
control->_apply_mouse_behavior_recursively(p_mouse_recursive_behavior, true);
|
control->_propagate_mouse_behavior_recursively(p_mouse_recursive_behavior, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3450,8 +3458,8 @@ void Control::_notification(int p_notification) {
|
||||||
|
|
||||||
_update_layout_mode();
|
_update_layout_mode();
|
||||||
|
|
||||||
set_focus_recursive_behavior(data.focus_recursive_behavior);
|
_set_focus_recursive_behavior_ignore_cache(data.focus_recursive_behavior);
|
||||||
set_mouse_recursive_behavior(data.mouse_recursive_behavior);
|
_set_mouse_recursive_behavior_ignore_cache(data.mouse_recursive_behavior);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_UNPARENTED: {
|
case NOTIFICATION_UNPARENTED: {
|
||||||
|
|
|
||||||
|
|
@ -330,8 +330,10 @@ private:
|
||||||
void _window_find_focus_neighbor(const Vector2 &p_dir, Node *p_at, const Rect2 &p_rect, const Rect2 &p_clamp, real_t p_min, real_t &r_closest_dist_squared, Control **r_closest);
|
void _window_find_focus_neighbor(const Vector2 &p_dir, Node *p_at, const Rect2 &p_rect, const Rect2 &p_clamp, real_t p_min, real_t &r_closest_dist_squared, Control **r_closest);
|
||||||
Control *_get_focus_neighbor(Side p_side, int p_count = 0);
|
Control *_get_focus_neighbor(Side p_side, int p_count = 0);
|
||||||
bool _is_focus_disabled_recursively() const;
|
bool _is_focus_disabled_recursively() const;
|
||||||
void _apply_focus_behavior_recursively(RecursiveBehavior p_focus_recursive_behavior, bool p_force);
|
void _propagate_focus_behavior_recursively(RecursiveBehavior p_focus_recursive_behavior, bool p_force);
|
||||||
void _apply_mouse_behavior_recursively(RecursiveBehavior p_focus_recursive_behavior, bool p_force);
|
void _propagate_mouse_behavior_recursively(RecursiveBehavior p_focus_recursive_behavior, bool p_force);
|
||||||
|
void _set_mouse_recursive_behavior_ignore_cache(RecursiveBehavior p_recursive_mouse_behavior);
|
||||||
|
void _set_focus_recursive_behavior_ignore_cache(RecursiveBehavior p_recursive_mouse_behavior);
|
||||||
|
|
||||||
// Theming.
|
// Theming.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue