mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Fix focus cycle through window
This commit is contained in:
parent
e5ccaa79e2
commit
6b9641d364
2 changed files with 49 additions and 2 deletions
|
|
@ -162,7 +162,54 @@ TEST_CASE("[SceneTree][Control] Find next/prev valid focus") {
|
|||
CHECK_UNARY(ctrl->has_focus());
|
||||
}
|
||||
|
||||
SUBCASE("[SceneTree][Control] Has a sibling control but the parent node is not a control") {
|
||||
SUBCASE("[SceneTree][Control] Has a sibling control and the parent is a window") {
|
||||
Control *ctrl1 = memnew(Control);
|
||||
Control *ctrl2 = memnew(Control);
|
||||
Control *ctrl3 = memnew(Control);
|
||||
Window *win = SceneTree::get_singleton()->get_root();
|
||||
|
||||
ctrl1->set_focus_mode(Control::FocusMode::FOCUS_ALL);
|
||||
ctrl2->set_focus_mode(Control::FocusMode::FOCUS_ALL);
|
||||
ctrl3->set_focus_mode(Control::FocusMode::FOCUS_ALL);
|
||||
|
||||
ctrl2->add_child(ctrl3);
|
||||
win->add_child(ctrl1);
|
||||
win->add_child(ctrl2);
|
||||
|
||||
SUBCASE("[SceneTree][Control] Focus Next") {
|
||||
ctrl1->grab_focus();
|
||||
CHECK_UNARY(ctrl1->has_focus());
|
||||
|
||||
SEND_GUI_ACTION("ui_focus_next");
|
||||
CHECK_UNARY(ctrl2->has_focus());
|
||||
|
||||
SEND_GUI_ACTION("ui_focus_next");
|
||||
CHECK_UNARY(ctrl3->has_focus());
|
||||
|
||||
SEND_GUI_ACTION("ui_focus_next");
|
||||
CHECK_UNARY(ctrl1->has_focus());
|
||||
}
|
||||
|
||||
SUBCASE("[SceneTree][Control] Focus Prev") {
|
||||
ctrl1->grab_focus();
|
||||
CHECK_UNARY(ctrl1->has_focus());
|
||||
|
||||
SEND_GUI_ACTION("ui_focus_prev");
|
||||
CHECK_UNARY(ctrl3->has_focus());
|
||||
|
||||
SEND_GUI_ACTION("ui_focus_prev");
|
||||
CHECK_UNARY(ctrl2->has_focus());
|
||||
|
||||
SEND_GUI_ACTION("ui_focus_prev");
|
||||
CHECK_UNARY(ctrl1->has_focus());
|
||||
}
|
||||
|
||||
memdelete(ctrl3);
|
||||
memdelete(ctrl1);
|
||||
memdelete(ctrl2);
|
||||
}
|
||||
|
||||
SUBCASE("[SceneTree][Control] Has a sibling control but the parent node is not a control or window") {
|
||||
Control *other_ctrl = memnew(Control);
|
||||
intermediate->add_child(other_ctrl);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue