| 239 | } |
| 240 | |
| 241 | static void menuKeyCommands() { |
| 242 | ImGuiContext &g = *GImGui; |
| 243 | ImGuiIO &io = ImGui::GetIO(); |
| 244 | |
| 245 | if (io.OSXBehaviors ? io.KeySuper : io.KeyCtrl) { |
| 246 | if (ImGui::IsKeyPressed(SDLK_n) && !io.KeyShift && !io.KeyAlt) |
| 247 | menuNewBank(); |
| 248 | if (ImGui::IsKeyPressed(SDLK_o) && !io.KeyShift && !io.KeyAlt) |
| 249 | menuOpenBank(); |
| 250 | if (ImGui::IsKeyPressed(SDLK_s) && !io.KeyShift && !io.KeyAlt) |
| 251 | menuSaveBank(); |
| 252 | if (ImGui::IsKeyPressed(SDLK_s) && io.KeyShift && !io.KeyAlt) |
| 253 | menuSaveBankAs(); |
| 254 | if (ImGui::IsKeyPressed(SDLK_q) && !io.KeyShift && !io.KeyAlt) |
| 255 | menuQuit(); |
| 256 | if (ImGui::IsKeyPressed(SDLK_z) && !io.KeyShift && !io.KeyAlt) |
| 257 | historyUndo(); |
| 258 | if (ImGui::IsKeyPressed(SDLK_z) && io.KeyShift && !io.KeyAlt) |
| 259 | historyRedo(); |
| 260 | if (ImGui::IsKeyPressed(SDLK_a) && !io.KeyShift && !io.KeyAlt) |
| 261 | menuSelectAll(); |
| 262 | if (ImGui::IsKeyPressed(SDLK_c) && !io.KeyShift && !io.KeyAlt) |
| 263 | menuCopy(); |
| 264 | if (ImGui::IsKeyPressed(SDLK_x) && !io.KeyShift && !io.KeyAlt) |
| 265 | menuCut(); |
| 266 | if (ImGui::IsKeyPressed(SDLK_v) && !io.KeyShift && !io.KeyAlt) |
| 267 | menuPaste(); |
| 268 | } |
| 269 | // I have NO idea why the scancode is needed here but the keycodes are needed for the letters. |
| 270 | // It looks like SDLZ_F1 is not defined correctly or something. |
| 271 | if (ImGui::IsKeyPressed(SDL_SCANCODE_F1)) |
| 272 | menuManual(); |
| 273 | |
| 274 | if (!io.KeySuper && !io.KeyCtrl && !io.KeyShift && !io.KeyAlt) { |
| 275 | // Only trigger these key commands if no text box is focused |
| 276 | if (!g.ActiveId || g.ActiveId != GImGui->InputTextState.Id) { |
| 277 | if (ImGui::IsKeyPressed(SDLK_r)) |
| 278 | menuRandomize(); |
| 279 | if (ImGui::IsKeyPressed(io.OSXBehaviors ? SDLK_BACKSPACE : SDLK_DELETE)) |
| 280 | menuClear(); |
| 281 | // Pages |
| 282 | if (ImGui::IsKeyPressed(SDLK_SPACE)) |
| 283 | playEnabled = !playEnabled; |
| 284 | if (ImGui::IsKeyPressed(SDLK_1)) |
| 285 | currentPage = EDITOR_PAGE; |
| 286 | if (ImGui::IsKeyPressed(SDLK_2)) |
| 287 | currentPage = EFFECT_PAGE; |
| 288 | if (ImGui::IsKeyPressed(SDLK_3)) |
| 289 | currentPage = GRID_PAGE; |
| 290 | if (ImGui::IsKeyPressed(SDLK_4)) |
| 291 | currentPage = WATERFALL_PAGE; |
| 292 | if (ImGui::IsKeyPressed(SDLK_5)) |
| 293 | currentPage = IMPORT_PAGE; |
| 294 | if (ImGui::IsKeyPressed(SDLK_6)) |
| 295 | currentPage = DB_PAGE; |
| 296 | if (ImGui::IsKeyPressed(SDL_SCANCODE_UP)) |
| 297 | incrementSelectedId(currentPage == GRID_PAGE ? -BANK_GRID_WIDTH : -1); |
| 298 | if (ImGui::IsKeyPressed(SDL_SCANCODE_DOWN)) |
no test coverage detected