Skip to content

Commit 5c51489

Browse files
committed
Fix tab focus/transition + keyboard shortcuts
- Add ImGui::SetKeyboardFocusHere after tab click for proper focus - Add Ctrl+Tab/Ctrl+Shift+Tab for keyboard tab switching - Add About dialog ImGui::OpenPopup
1 parent 5ffe1da commit 5c51489

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

imgui.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ Collapsed=0
3131
Size=1280,800
3232
Collapsed=0
3333

34+
[Window][About]
35+
Pos=212,176
36+
Size=580,270
37+
Collapsed=0
38+
3439
[Docking][Data]
3540
DockNode ID=0x00000006 Pos=236,483 Size=1280,800 Split=X
3641
DockNode ID=0x00000001 Parent=0x00000006 SizeRef=225,357 Split=Y

src/editor_app.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,14 @@ void EditorApp::render() {
19491949
}
19501950
return;
19511951
}
1952+
// Ctrl+Tab - next tab
1953+
if (ImGui::IsKeyPressed(ImGuiKey_Tab)) {
1954+
if (tabs_.size() > 1) {
1955+
active_tab_ = (active_tab_ + 1) % tabs_.size();
1956+
ImGui::SetWindowFocus("Editor");
1957+
}
1958+
return;
1959+
}
19521960
}
19531961
if (io.KeyCtrl && io.KeyShift && !io.KeyAlt) {
19541962
if (ImGui::IsKeyPressed(ImGuiKey_N)) { new_window(); return; }
@@ -1957,6 +1965,14 @@ void EditorApp::render() {
19571965
if (ImGui::IsKeyPressed(ImGuiKey_P)) { show_cmd_palette_ = true; return; }
19581966
if (ImGui::IsKeyPressed(ImGuiKey_H)) { split_horizontal(); return; }
19591967
if (ImGui::IsKeyPressed(ImGuiKey_V)) { split_vertical(); return; }
1968+
// Ctrl+Shift+Tab - previous tab
1969+
if (ImGui::IsKeyPressed(ImGuiKey_Tab)) {
1970+
if (tabs_.size() > 1) {
1971+
active_tab_ = (active_tab_ - 1 + (int)tabs_.size()) % tabs_.size();
1972+
ImGui::SetWindowFocus("Editor");
1973+
}
1974+
return;
1975+
}
19601976
}
19611977
if (io.KeyCtrl && io.KeyAlt && !io.KeyShift) {
19621978
if (ImGui::IsKeyPressed(ImGuiKey_S)) { save_all(); return; }
@@ -2374,6 +2390,7 @@ void EditorApp::render_editor_area() {
23742390
if (active_tab_ != i) {
23752391
active_tab_ = i;
23762392
ImGui::SetWindowFocus("Editor");
2393+
ImGui::SetKeyboardFocusHere();
23772394
}
23782395
ImGui::EndTabItem();
23792396
}

0 commit comments

Comments
 (0)