Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Make buttons work with keypresses #86

Merged
merged 4 commits into from
Aug 1, 2019
Merged

Conversation

LukeSlev
Copy link
Member

@LukeSlev LukeSlev commented Aug 1, 2019

Description:

This PR lets keypresses press the buttons on the webview.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Testing:

  • keypress a and A press button a
  • keypress b and B press button b
  • keypress s and S toggle switch
  • keypress R press refresh button
  • keypress F press start button

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

this.setState({ ...this.state, play_button: !this.state.play_button });
sendMessage("play-simulator", !this.state.play_button);
const button =
Copy link
Member

Choose a reason for hiding this comment

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

If this is a play action, would the button focus go to the stop button? The code here seems to keep focus on the play button.

Copy link
Member Author

Choose a reason for hiding this comment

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

So maybe this is just poorly named. The play button is also the stop button when the code is running so this is grabbing whichever icon is available. I can rename this if that helps! @adclements

if (target === undefined) {
return;
}
console.log("event", event);
if ([event.code, event.key].includes(CONSTANTS.KEYBOARD_KEYS.ENTER)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The if case seems to be building up. If we don't have any more sensors that require key press functionality, this should be fine?

Copy link
Member Author

Choose a reason for hiding this comment

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

Any ideas on how to do this differently? I don't have any off the top of my head

Copy link
Contributor

@markAtMicrosoft markAtMicrosoft Aug 1, 2019

Choose a reason for hiding this comment

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

does changing to a switch statement make sense?

BUTTON_A: "BTN_A_OUTER",
BUTTON_AB: "BTN_AB_OUTER",
BUTTON_B: "BTN_B_OUTER",
PLAY_BUTTON: "play-button",
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to keep consistent with naming convention here in the future. There appears to be uppercase with underscores and lowercase with dashes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to just change either the class name or id name since I think having these together is good. I wouldn't separate it.

@jonathanwangg
Copy link
Contributor

I'm running into an issue where if I press SHIFT+F, the image of the play / stop button flickers an extra time. Have you noticed this?

@LukeSlev
Copy link
Member Author

LukeSlev commented Aug 1, 2019

@jonthanwangg made changes!

@LukeSlev LukeSlev merged commit 28abe23 into dev Aug 1, 2019
@LukeSlev LukeSlev deleted the users/t-luslev/keypress-buttons branch August 7, 2019 23:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants