pxt-microbit 7.1.36 → 7.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/built/sim.d.ts CHANGED
@@ -891,6 +891,7 @@ declare namespace pxsim.visuals {
891
891
  private attachABEvents;
892
892
  attachButtonEvents(stateButton: Button, buttonOuter: SVGElement, elButton: SVGElement): void;
893
893
  private attachAPlusBEvents;
894
+ private attachKeyboardEvents;
894
895
  }
895
896
  }
896
897
  declare namespace pxsim {
package/built/sim.js CHANGED
@@ -132,12 +132,12 @@ var pxsim;
132
132
  highContrast: msg.highContrast
133
133
  }), opts);
134
134
  document.body.innerHTML = ""; // clear children
135
- document.body.appendChild(this.view = this.viewHost.getView());
136
135
  if (pxsim.shouldShowMute()) {
137
136
  document.body.appendChild(pxsim.createMuteButton());
138
137
  pxsim.AudioContextManager.mute(true);
139
138
  pxsim.setParentMuteState("disabled");
140
139
  }
140
+ document.body.appendChild(this.view = this.viewHost.getView());
141
141
  if (msg.theme === "mbcodal") {
142
142
  this.ensureHardwareVersion(2);
143
143
  }
@@ -4088,17 +4088,26 @@ var pxsim;
4088
4088
  outline: none;
4089
4089
  }
4090
4090
  *:focus .sim-button-outer,
4091
- .sim-antenna-outer:focus,
4092
- .sim-pin:focus,
4093
- .sim-thermometer:focus,
4094
4091
  .sim-shake:focus,
4095
- .sim-light-level-button:focus {
4096
- stroke: #4D90FE;
4097
- stroke-width: 5px !important;
4092
+ .sim-thermometer:focus {
4093
+ outline: 5px solid white;
4094
+ stroke: black;
4095
+ stroke-width: 10px;
4096
+ paint-order: stroke;
4098
4097
  }
4099
4098
  .sim-button-outer.sim-button-group:focus > .sim-button {
4100
- stroke: #4D90FE;
4101
- stroke-width: 10px !important;
4099
+ outline: 5px solid white;
4100
+ stroke: black;
4101
+ stroke-width: 5px;
4102
+ paint-order: stroke;
4103
+ }
4104
+ .sim-light-level-button:focus,
4105
+ .sim-antenna-outer:focus > .sim-antenna {
4106
+ outline: 5px solid white;
4107
+ }
4108
+ .sim-pin:focus {
4109
+ stroke: white;
4110
+ stroke-width: 5px !important;
4102
4111
  }
4103
4112
  .no-drag, .sim-text, .sim-text-small,
4104
4113
  .sim-text-pin {
@@ -4595,12 +4604,40 @@ path.sim-board {
4595
4604
  p.setAttribute("d", "m269.9,50.134647l0,0l-39.5,0l0,0c-14.1,0.1 -24.6,10.7 -24.6,24.8c0,13.9 10.4,24.4 24.3,24.7l0,0l39.6,0c14.2,0 40.36034,-22.97069 40.36034,-24.85394c0,-1.88326 -26.06034,-24.54606 -40.16034,-24.64606m-0.2,39l0,0l-39.3,0c-7.7,-0.1 -14,-6.4 -14,-14.2c0,-7.8 6.4,-14.2 14.2,-14.2l39.1,0c7.8,0 14.2,6.4 14.2,14.2c0,7.9 -6.4,14.2 -14.2,14.2l0,0l0,0z");
4596
4605
  this.updateTheme();
4597
4606
  let pt = this.element.createSVGPoint();
4598
- pxsim.svg.buttonEvents(this.head, (ev) => {
4607
+ pxsim.svg.buttonEvents(this.head,
4608
+ // move
4609
+ (ev) => {
4599
4610
  let cur = pxsim.svg.cursorPoint(pt, this.element, ev);
4600
4611
  state.compassState.heading = Math.floor(Math.atan2(cur.y - yc, cur.x - xc) * 180 / Math.PI) + 90;
4601
4612
  if (state.compassState.heading < 0)
4602
4613
  state.compassState.heading += 360;
4603
4614
  this.updateHeading();
4615
+ },
4616
+ // start
4617
+ ev => { },
4618
+ // stop
4619
+ ev => { },
4620
+ // keydown
4621
+ (ev) => {
4622
+ let charCode = (typeof ev.which == "number") ? ev.which : ev.keyCode;
4623
+ if (charCode === 40 || charCode === 37) { // Down/Left arrow
4624
+ ev.preventDefault();
4625
+ state.compassState.heading--;
4626
+ if (state.compassState.heading < 0)
4627
+ state.compassState.heading += 360;
4628
+ if (state.compassState.heading >= 360)
4629
+ state.compassState.heading %= 360;
4630
+ this.updateHeading();
4631
+ }
4632
+ else if (charCode === 38 || charCode === 39) { // Up/Right arrow
4633
+ ev.preventDefault();
4634
+ state.compassState.heading++;
4635
+ if (state.compassState.heading < 0)
4636
+ state.compassState.heading += 360;
4637
+ if (state.compassState.heading >= 360)
4638
+ state.compassState.heading %= 360;
4639
+ this.updateHeading();
4640
+ }
4604
4641
  });
4605
4642
  this.headInitialized = true;
4606
4643
  }
@@ -4611,6 +4648,9 @@ path.sim-board {
4611
4648
  if (this.props.runtime)
4612
4649
  this.props.runtime.environmentGlobals[pxsim.localization.lf("heading")] = state.compassState.heading;
4613
4650
  }
4651
+ // make sim head focusable when there is a compass
4652
+ this.headParts.setAttribute("class", "sim-button-outer sim-button-group");
4653
+ pxsim.accessibility.makeFocusable(this.headParts);
4614
4654
  }
4615
4655
  flashSystemLed() {
4616
4656
  if (!this.systemLed)
@@ -5119,6 +5159,7 @@ path.sim-board {
5119
5159
  this.attachPinsTouchEvents();
5120
5160
  this.attachABEvents();
5121
5161
  this.attachAPlusBEvents();
5162
+ this.attachKeyboardEvents();
5122
5163
  }
5123
5164
  attachIFrameEvents() {
5124
5165
  pxsim.Runtime.messagePosted = (msg) => {
@@ -5364,6 +5405,9 @@ path.sim-board {
5364
5405
  this.board.bus.queue(bpState.abBtn.id, 3 /* DAL.MICROBIT_BUTTON_EVT_CLICK */);
5365
5406
  });
5366
5407
  }
5408
+ attachKeyboardEvents() {
5409
+ pxsim.accessibility.postKeyboardEvent();
5410
+ }
5367
5411
  }
5368
5412
  visuals.MicrobitBoardSvg = MicrobitBoardSvg;
5369
5413
  })(visuals = pxsim.visuals || (pxsim.visuals = {}));
@@ -5377,7 +5421,7 @@ var pxsim;
5377
5421
  const el = document.createElement("div");
5378
5422
  el.setAttribute("id", "safari-mute-button-outer");
5379
5423
  el.innerHTML = `
5380
- <button class="safari-mute-button">
5424
+ <button class="safari-mute-button" tabindex="1">
5381
5425
  ${icon}
5382
5426
  </button>
5383
5427
  `;