pxt-microbit 5.0.1 → 5.0.4

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
@@ -747,6 +747,7 @@ declare namespace pxsim.visuals {
747
747
  private attachPinsIOEvents;
748
748
  private attachPinsTouchEvents;
749
749
  private attachABEvents;
750
+ attachButtonEvents(stateButton: Button, buttonOuter: SVGElement, elButton: SVGElement): void;
750
751
  private attachAPlusBEvents;
751
752
  }
752
753
  }
package/built/sim.js CHANGED
@@ -2608,6 +2608,9 @@ var pxsim;
2608
2608
  .sim-button {
2609
2609
  pointer-events: none;
2610
2610
  }
2611
+ .sim-head .sim-button {
2612
+ pointer-events: unset;
2613
+ }
2611
2614
  .sim-board, .sim-display, sim-button {
2612
2615
  fill: #111;
2613
2616
  }
@@ -2903,10 +2906,12 @@ path.sim-board {
2903
2906
  pxsim.svg.fill(this.buttonsOuter[2], theme.virtualButtonOuter);
2904
2907
  pxsim.svg.fill(this.buttons[2], theme.virtualButtonUp);
2905
2908
  pxsim.svg.fills(this.logos, theme.accent);
2906
- if (this.domHardwareVersion > 1)
2909
+ if (this.domHardwareVersion > 1) {
2907
2910
  pxsim.svg.fills(this.heads.slice(1), "gold");
2908
- else
2911
+ }
2912
+ else {
2909
2913
  pxsim.svg.fills(this.heads.slice(1), theme.accent);
2914
+ }
2910
2915
  if (this.shakeButton)
2911
2916
  pxsim.svg.fill(this.shakeButton, theme.virtualButtonUp);
2912
2917
  this.pinGradients.forEach(lg => pxsim.svg.setGradientColors(lg, theme.pin, theme.pinActive));
@@ -3480,7 +3485,7 @@ path.sim-board {
3480
3485
  // head
3481
3486
  this.head = pxsim.svg.child(this.g, "g", { class: "sim-head" });
3482
3487
  pxsim.svg.child(this.head, "circle", { cx: 258, cy: 75, r: 100, fill: "transparent" });
3483
- this.headParts = pxsim.svg.child(this.head, "g", { class: "sim-button-outer sim-button-group" });
3488
+ this.headParts = pxsim.svg.child(this.head, "g", {});
3484
3489
  this.heads = [];
3485
3490
  // background
3486
3491
  this.heads.push(pxsim.svg.path(this.headParts, "sim-button", "M 269.9 50.2 L 269.9 50.2 l -39.5 0 v 0 c -14.1 0.1 -24.6 10.7 -24.6 24.8 c 0 13.9 10.4 24.4 24.3 24.7 v 0 h 39.6 c 14.2 0 24.8 -10.6 24.8 -24.7 C 294.5 61 284 50.3 269.9 50.2 M 269.7 89.2"));
@@ -3587,6 +3592,8 @@ path.sim-board {
3587
3592
  const headTitle = pxsim.localization.lf("logo touch (micro:bit v2 needed)");
3588
3593
  pxsim.accessibility.makeFocusable(this.headParts);
3589
3594
  pxsim.accessibility.setAria(this.headParts, "button", headTitle);
3595
+ this.headParts.setAttribute("class", "sim-button-outer sim-button-group");
3596
+ this.attachButtonEvents(this.board.logoTouch, this.headParts, this.headParts);
3590
3597
  // microphone led
3591
3598
  const microphoneTitle = pxsim.localization.lf("microphone (micro:bit v2 needed)");
3592
3599
  const microg = pxsim.svg.child(this.g, "g", { title: microphoneTitle });
@@ -3785,38 +3792,41 @@ path.sim-board {
3785
3792
  }
3786
3793
  attachABEvents() {
3787
3794
  const bpState = this.board.buttonPairState;
3788
- const stateButtons = [bpState.aBtn, bpState.bBtn, this.board.logoTouch];
3789
- const elButtonOuters = this.buttonsOuter.slice(0, 2).concat(this.headParts);
3790
- const elButtons = this.buttons.slice(0, 2).concat(this.headParts);
3795
+ const stateButtons = [bpState.aBtn, bpState.bBtn];
3796
+ const elButtonOuters = this.buttonsOuter.slice(0, 2);
3797
+ const elButtons = this.buttons.slice(0, 2);
3791
3798
  elButtonOuters.forEach((btn, index) => {
3792
- let pressedTime;
3793
- pxsim.pointerEvents.down.forEach(evid => btn.addEventListener(evid, ev => {
3794
- console.log(`down ${stateButtons[index].id}`);
3795
- stateButtons[index].pressed = true;
3796
- pxsim.svg.fill(elButtons[index], this.props.theme.buttonDown);
3797
- this.board.bus.queue(stateButtons[index].id, 1 /* MICROBIT_BUTTON_EVT_DOWN */);
3798
- pressedTime = pxsim.runtime.runningTime();
3799
- }));
3800
- btn.addEventListener(pxsim.pointerEvents.leave, ev => {
3801
- stateButtons[index].pressed = false;
3802
- pxsim.svg.fill(elButtons[index], this.props.theme.buttonUp);
3803
- });
3804
- btn.addEventListener(pxsim.pointerEvents.up, ev => {
3805
- stateButtons[index].pressed = false;
3806
- pxsim.svg.fill(elButtons[index], this.props.theme.buttonUp);
3807
- this.board.bus.queue(stateButtons[index].id, 2 /* MICROBIT_BUTTON_EVT_UP */);
3808
- const currentTime = pxsim.runtime.runningTime();
3809
- if (currentTime - pressedTime > 1000 /* DEVICE_BUTTON_LONG_CLICK_TIME */)
3810
- this.board.bus.queue(stateButtons[index].id, 4 /* MICROBIT_BUTTON_EVT_LONG_CLICK */);
3811
- else
3812
- this.board.bus.queue(stateButtons[index].id, 3 /* MICROBIT_BUTTON_EVT_CLICK */);
3813
- pressedTime = undefined;
3814
- });
3815
- pxsim.accessibility.enableKeyboardInteraction(btn, undefined, () => {
3816
- this.board.bus.queue(stateButtons[index].id, 1 /* MICROBIT_BUTTON_EVT_DOWN */);
3817
- this.board.bus.queue(stateButtons[index].id, 2 /* MICROBIT_BUTTON_EVT_UP */);
3818
- this.board.bus.queue(stateButtons[index].id, 3 /* MICROBIT_BUTTON_EVT_CLICK */);
3819
- });
3799
+ this.attachButtonEvents(stateButtons[index], btn, elButtons[index]);
3800
+ });
3801
+ }
3802
+ attachButtonEvents(stateButton, buttonOuter, elButton) {
3803
+ let pressedTime;
3804
+ pxsim.pointerEvents.down.forEach(evid => buttonOuter.addEventListener(evid, ev => {
3805
+ // console.log(`down ${stateButton.id}`)
3806
+ stateButton.pressed = true;
3807
+ pxsim.svg.fill(elButton, this.props.theme.buttonDown);
3808
+ this.board.bus.queue(stateButton.id, 1 /* MICROBIT_BUTTON_EVT_DOWN */);
3809
+ pressedTime = pxsim.runtime.runningTime();
3810
+ }));
3811
+ buttonOuter.addEventListener(pxsim.pointerEvents.leave, ev => {
3812
+ stateButton.pressed = false;
3813
+ pxsim.svg.fill(elButton, this.props.theme.buttonUp);
3814
+ });
3815
+ buttonOuter.addEventListener(pxsim.pointerEvents.up, ev => {
3816
+ stateButton.pressed = false;
3817
+ pxsim.svg.fill(elButton, this.props.theme.buttonUp);
3818
+ this.board.bus.queue(stateButton.id, 2 /* MICROBIT_BUTTON_EVT_UP */);
3819
+ const currentTime = pxsim.runtime.runningTime();
3820
+ if (currentTime - pressedTime > 1000 /* DEVICE_BUTTON_LONG_CLICK_TIME */)
3821
+ this.board.bus.queue(stateButton.id, 4 /* MICROBIT_BUTTON_EVT_LONG_CLICK */);
3822
+ else
3823
+ this.board.bus.queue(stateButton.id, 3 /* MICROBIT_BUTTON_EVT_CLICK */);
3824
+ pressedTime = undefined;
3825
+ });
3826
+ pxsim.accessibility.enableKeyboardInteraction(buttonOuter, undefined, () => {
3827
+ this.board.bus.queue(stateButton.id, 1 /* MICROBIT_BUTTON_EVT_DOWN */);
3828
+ this.board.bus.queue(stateButton.id, 2 /* MICROBIT_BUTTON_EVT_UP */);
3829
+ this.board.bus.queue(stateButton.id, 3 /* MICROBIT_BUTTON_EVT_CLICK */);
3820
3830
  });
3821
3831
  }
3822
3832
  attachAPlusBEvents() {