From 8dbcfa2cf2a2b6c3558f6cdd4e001746b4f2f254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Cie=C5=9Blak?= Date: Mon, 28 Sep 2015 11:50:44 +0200 Subject: [PATCH] Additional shortcut keys, space, ctrl+s/o/n --- libalgaudio/MainWindow.cpp | 14 ++++++++++++++ libalgaudio/Utilities.cpp | 2 ++ libalgaudio/include/Utilities.hpp | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libalgaudio/MainWindow.cpp b/libalgaudio/MainWindow.cpp index 51285c2..fd2b0fb 100644 --- a/libalgaudio/MainWindow.cpp +++ b/libalgaudio/MainWindow.cpp @@ -267,6 +267,20 @@ void MainWindow::ProcessCloseEvent(){ void MainWindow::ProcessKeyboardEvent(KeyData data){ // Pass all key events to the canvasview. + if(data.ctrl && data.type == KeyData::KeyType::Letter && data.symbol == "s" && data.IsTrig()){ + Save(); return; + } + if(data.ctrl && data.type == KeyData::KeyType::Letter && data.symbol == "n" && data.IsTrig()){ + New(); return; + } + if(data.ctrl && data.type == KeyData::KeyType::Letter && data.symbol == "o" && data.IsTrig()){ + Open(); return; + } + if(data.type == KeyData::KeyType::Space && data.IsTrig()){ + if(selector->IsExposed()) selector->Hide(); + else selector->Expose(); + return; + } canvasview->OnKeyboard(data); } diff --git a/libalgaudio/Utilities.cpp b/libalgaudio/Utilities.cpp index e51a80e..2baea2c 100644 --- a/libalgaudio/Utilities.cpp +++ b/libalgaudio/Utilities.cpp @@ -279,6 +279,8 @@ void KeyData::InitKeymap(){ keymap[SDLK_y] = {"y", Letter}; keymap[SDLK_z] = {"z", Letter}; + keymap[SDLK_SPACE] = {" ", Space}; + keymap[SDLK_EQUALS] = {"=", Symbol}; keymap[SDLK_MINUS] = {"-", Symbol}; keymap[SDLK_KP_PLUS] = {"+", Symbol}; diff --git a/libalgaudio/include/Utilities.hpp b/libalgaudio/include/Utilities.hpp index 3bf736f..1f781b6 100644 --- a/libalgaudio/include/Utilities.hpp +++ b/libalgaudio/include/Utilities.hpp @@ -165,7 +165,8 @@ struct KeyData{ Backspace, Delete, Return, Shift, Ctrl, Alt, - Escape + Escape, + Space }; KeyData(const SDL_KeyboardEvent&); /** This constructor creates a Text key data (See SDL's TextInput) */