Skip to content

Commit

Permalink
Additional shortcut keys, space, ctrl+s/o/n
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalcieslak committed Sep 28, 2015
1 parent 6a22ff5 commit 8dbcfa2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions libalgaudio/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions libalgaudio/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 2 additions & 1 deletion libalgaudio/include/Utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down

0 comments on commit 8dbcfa2

Please sign in to comment.