Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C2LC-431: Add Keyboard shortcut for expand and collapse add nodes #230

Open
wants to merge 4 commits into
base: develop-1.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/keyboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ follows.
| < | decreaseProgramSpeed |
| > | increaseProgramSpeed |
| ? | showHide |
| + | expandAddNode |
| Ctrl + Alt + x, a, b, 1 | selectBackward1 |
| Ctrl + Alt + x, a, b, 2 | selectBackward2 |
| Ctrl + Alt + x, a, b, 3 | selectBackward3 |
Expand Down Expand Up @@ -92,6 +93,7 @@ with the starting key of a sequence. Those key bindings are as follows:
| < | decreaseProgramSpeed |
| > | increaseProgramSpeed |
| ? | showHide |
| + | expandAddNode |
| Alt + x, a, b, 1 | selectBackward1 |
| Alt + x, a, b, 2 | selectBackward2 |
| Alt + x, a, b, 3 | selectBackward3 |
Expand Down
4 changes: 4 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,10 @@ export class App extends React.Component<AppProps, AppState> {
this.handleChangeCharacterPosition('turnRight');
}
break;
case("expandAddNode"):
const currentAddNodeState = this.state.settings.addNodeExpandedMode;
this.handleChangeAddNodeExpandedMode(!currentAddNodeState);
break;
case("changeToDefaultTheme"):
this.setStateSettings({theme: "mixed"});
break;
Expand Down
9 changes: 9 additions & 0 deletions src/KeyboardInputSchemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type ActionName =
| "addCommandToBeginning"
| "addCommandToEnd"
| "deleteCurrentStep"
| "expandAddNode"
| "announceScene"
| "decreaseProgramSpeed"
| "increaseProgramSpeed"
Expand Down Expand Up @@ -321,6 +322,10 @@ const AltInputScheme: KeyboardInputScheme = Object.assign({
stopProgram: {
keyDef: { code: "KeyS", key: "s", altKey: true},
actionName: "stopProgram"
},
expandAddNode: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now this is fine, but as we pick up more bindings (like the help key) that are the same between all schemes, we should probably make and reuse a "common" binding definition, like we do with extended keyboard sequences. I think a TODO here would be a good idea for now.

Copy link
Contributor Author

@chosww chosww Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current keyboard shortcut combinations are likely to change, so I think it makes sense to wait until we talk about rework of the keyboard shortcut combinations.

keyDef: { key: "+"},
actionName: "expandAddNode"
}
}, ExtendedKeyboardSequences);

Expand Down Expand Up @@ -387,6 +392,10 @@ const ControlAltInputScheme = Object.assign({
keyDef: {code: "KeyS", key: "s", altKey: true, ctrlKey: true},
actionName: "stopProgram"
},
expandAddNode: {
keyDef: { key: "+", shiftKey: true},
actionName: "expandAddNode"
}
}, ControlAltExtendedKeyboardSequences);

export const KeyboardInputSchemes:KeyboardInputSchemesType = {
Expand Down