-
-
-
+ The simulator will run the .py file you have focused on.
{
play_button: false,
selected_file: "",
active_editors: [],
- running_file: "",
+ running_file: undefined,
+ currently_selected_file: "",
};
this.onKeyEvent = this.onKeyEvent.bind(this);
}
@@ -71,8 +72,10 @@ export class MicrobitSimulator extends React.Component
{
});
break;
case "activate-play":
+ const newRunningFile = this.state.currently_selected_file;
this.setState({
play_button: !this.state.play_button,
+ running_file: newRunningFile,
});
break;
case "visible-editors":
@@ -81,9 +84,17 @@ export class MicrobitSimulator extends React.Component {
});
break;
case "current-file":
- this.setState({
- running_file: message.state.running_file,
- });
+ if (this.state.play_button) {
+ this.setState({
+ currently_selected_file: message.state.running_file,
+ });
+ } else {
+ this.setState({
+ running_file: message.state.running_file,
+ currently_selected_file: message.state.running_file,
+ });
+ }
+
break;
}
};
@@ -100,14 +111,9 @@ export class MicrobitSimulator extends React.Component {
return (
-
+ {this.state.running_file && this.state.play_button
+ ? CONSTANTS.CURRENTLY_RUNNING(this.state.running_file)
+ : CONSTANTS.FILES_PLACEHOLDER}
{
);
}
+
protected togglePlayClick = () => {
const button =
window.document.getElementById(CONSTANTS.ID_NAME.PLAY_BUTTON) ||
@@ -142,11 +149,7 @@ export class MicrobitSimulator extends React.Component
{
state: !this.state.play_button,
});
};
- protected onSelectFile(event: React.FocusEvent) {
- this.setState({
- selected_file: event.currentTarget.value,
- });
- }
+
protected refreshSimulatorClick = () => {
const button = window.document.getElementById(
CONSTANTS.ID_NAME.REFRESH_BUTTON
diff --git a/src/view/constants.ts b/src/view/constants.ts
index 55ba35bf5..d81683ef2 100644
--- a/src/view/constants.ts
+++ b/src/view/constants.ts
@@ -42,7 +42,8 @@ export const CONSTANTS = {
NUMERIC_SIX: "Digit6",
NUMERIC_SEVEN: "Digit7",
},
- NO_FILES_AVAILABLE: "Choose a .py file to run on the Simulator",
+ FILES_PLACEHOLDER:
+ "The simulator will run the .py file you have focused on.",
SIMULATOR_BUTTON_WIDTH: 60,
TOOLBAR_INFO: `Explore what's on the board:`,
};
diff --git a/src/view/container/device/__snapshots__/Device.spec.tsx.snap b/src/view/container/device/__snapshots__/Device.spec.tsx.snap
index 5340ff299..bc04b0685 100644
--- a/src/view/container/device/__snapshots__/Device.spec.tsx.snap
+++ b/src/view/container/device/__snapshots__/Device.spec.tsx.snap
@@ -10,21 +10,7 @@ exports[`Device component should render correctly 1`] = `
-
-
-
+ The simulator will run the .py file you have focused on.