Merge pull request #62557 from KoBeWi/find_next_valid_freeze

This commit is contained in:
Rémi Verschelde 2022-06-30 19:04:41 +02:00 committed by GitHub
commit 55048b1ca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 9 deletions

View File

@ -2344,7 +2344,7 @@ void Control::set_focus_mode(FocusMode p_focus_mode) {
static Control *_next_control(Control *p_from) { static Control *_next_control(Control *p_from) {
if (p_from->is_set_as_top_level()) { if (p_from->is_set_as_top_level()) {
return nullptr; // can't go above return nullptr; // Can't go above.
} }
Control *parent = Object::cast_to<Control>(p_from->get_parent()); Control *parent = Object::cast_to<Control>(p_from->get_parent());
@ -2364,7 +2364,7 @@ static Control *_next_control(Control *p_from) {
return c; return c;
} }
//no next in parent, try the same in parent // No next in parent, try the same in parent.
return _next_control(parent); return _next_control(parent);
} }
@ -2388,7 +2388,7 @@ Control *Control::find_next_valid_focus() const {
} }
} }
// find next child // Find next child.
Control *next_child = nullptr; Control *next_child = nullptr;
@ -2404,7 +2404,7 @@ Control *Control::find_next_valid_focus() const {
if (!next_child) { if (!next_child) {
next_child = _next_control(from); next_child = _next_control(from);
if (!next_child) { //nothing else.. go up and find either window or subwindow if (!next_child) { // Nothing else. Go up and find either window or subwindow.
next_child = const_cast<Control *>(this); next_child = const_cast<Control *>(this);
while (next_child && !next_child->is_set_as_top_level()) { while (next_child && !next_child->is_set_as_top_level()) {
next_child = cast_to<Control>(next_child->get_parent()); next_child = cast_to<Control>(next_child->get_parent());
@ -2422,7 +2422,7 @@ Control *Control::find_next_valid_focus() const {
} }
} }
if (next_child == this) { // no next control-> if (next_child == from) { // No next control.
return (get_focus_mode() == FOCUS_ALL) ? next_child : nullptr; return (get_focus_mode() == FOCUS_ALL) ? next_child : nullptr;
} }
if (next_child) { if (next_child) {
@ -2454,7 +2454,7 @@ static Control *_prev_control(Control *p_from) {
return p_from; return p_from;
} }
//no prev in parent, try the same in parent // No prev in parent, try the same in parent.
return _prev_control(child); return _prev_control(child);
} }
@ -2478,12 +2478,12 @@ Control *Control::find_prev_valid_focus() const {
} }
} }
// find prev child // Find prev child.
Control *prev_child = nullptr; Control *prev_child = nullptr;
if (from->is_set_as_top_level() || !Object::cast_to<Control>(from->get_parent())) { if (from->is_set_as_top_level() || !Object::cast_to<Control>(from->get_parent())) {
//find last of the children // Find last of the children.
prev_child = _prev_control(from); prev_child = _prev_control(from);
@ -2506,7 +2506,7 @@ Control *Control::find_prev_valid_focus() const {
} }
} }
if (prev_child == this) { // no prev control-> if (prev_child == from) { // No prev control.
return (get_focus_mode() == FOCUS_ALL) ? prev_child : nullptr; return (get_focus_mode() == FOCUS_ALL) ? prev_child : nullptr;
} }