@@ -8,7 +8,6 @@ import { sendMessage } from "../../utils/MessageUtils";
88import "../../styles/Simulator.css" ;
99import PlayLogo from "../../svgs/play_svg" ;
1010import StopLogo from "../../svgs/stop_svg" ;
11- import Dropdown from "../Dropdown" ;
1211import ActionBar from "../simulator/ActionBar" ;
1312import { BUTTON_NEUTRAL , BUTTON_PRESSED } from "./Cpx_svg_style" ;
1413import { CpxImage , updatePinTouch , updateSwitch } from "./CpxImage" ;
@@ -30,6 +29,7 @@ interface IState {
3029 selected_file : string ;
3130 cpx : ICpxState ;
3231 play_button : boolean ;
32+ currently_selected_file : string ;
3333}
3434
3535const DEFAULT_CPX_STATE : ICpxState = {
@@ -63,6 +63,7 @@ class Simulator extends React.Component<{}, IState> {
6363 play_button : false ,
6464 running_file : "" ,
6565 selected_file : "" ,
66+ currently_selected_file : "" ,
6667 } ;
6768
6869 this . handleClick = this . handleClick . bind ( this ) ;
@@ -72,7 +73,6 @@ class Simulator extends React.Component<{}, IState> {
7273 this . onMouseLeave = this . onMouseLeave . bind ( this ) ;
7374 this . togglePlayClick = this . togglePlayClick . bind ( this ) ;
7475 this . refreshSimulatorClick = this . refreshSimulatorClick . bind ( this ) ;
75- this . onSelectBlur = this . onSelectBlur . bind ( this ) ;
7676 }
7777
7878 handleMessage = ( event : any ) : void => {
@@ -98,8 +98,11 @@ class Simulator extends React.Component<{}, IState> {
9898 } ) ;
9999 break ;
100100 case "activate-play" :
101+ const newRunningFile = this . state . currently_selected_file ;
102+
101103 this . setState ( {
102104 play_button : ! this . state . play_button ,
105+ running_file : newRunningFile ,
103106 } ) ;
104107 break ;
105108 case "visible-editors" :
@@ -113,9 +116,16 @@ class Simulator extends React.Component<{}, IState> {
113116 break ;
114117 case "current-file" :
115118 console . log ( "Setting current file" , message . state . running_file ) ;
116- this . setState ( {
117- running_file : message . state . running_file ,
118- } ) ;
119+ if ( this . state . play_button ) {
120+ this . setState ( {
121+ currently_selected_file : message . state . running_file ,
122+ } ) ;
123+ } else {
124+ this . setState ( {
125+ running_file : message . state . running_file ,
126+ currently_selected_file : message . state . running_file ,
127+ } ) ;
128+ }
119129 break ;
120130 }
121131 } ;
@@ -136,14 +146,9 @@ class Simulator extends React.Component<{}, IState> {
136146 return (
137147 < div className = "simulator" >
138148 < div className = "file-selector" >
139- < Dropdown
140- label = { "file-dropdown" }
141- styleLabel = { "dropdown" }
142- lastChosen = { this . state . running_file }
143- width = { 300 }
144- textOptions = { this . state . active_editors }
145- onBlur = { this . onSelectBlur }
146- />
149+ { this . state . running_file && this . state . play_button
150+ ? CONSTANTS . CURRENTLY_RUNNING ( this . state . running_file )
151+ : CONSTANTS . FILES_PLACEHOLDER }
147152 </ div >
148153 < div className = "cpx-container" >
149154 < CpxImage
@@ -191,11 +196,6 @@ class Simulator extends React.Component<{}, IState> {
191196 sendMessage ( WEBVIEW_MESSAGES . REFRESH_SIMULATOR , true ) ;
192197 }
193198
194- protected onSelectBlur ( event : React . FocusEvent < HTMLSelectElement > ) {
195- this . setState ( {
196- selected_file : event . currentTarget . value ,
197- } ) ;
198- }
199199 protected onKeyEvent ( event : KeyboardEvent , active : boolean ) {
200200 let element ;
201201 const target = event . target as SVGElement ;
0 commit comments