@@ -39,8 +39,8 @@ namespace pxsim.visuals {
39
39
stroke-width:2px;
40
40
}
41
41
42
- .sim-pin-touch.touched:hover {
43
- stroke:darkorange;
42
+ .sim-pin-touch.touched {
43
+ stroke:darkorange !important ;
44
44
}
45
45
46
46
.sim-led-back:hover {
@@ -475,12 +475,12 @@ path.sim-board {
475
475
476
476
private updateButtonPairs ( ) {
477
477
const state = this . board ;
478
- const theme = this . props . theme ;
479
- const bpState = state . buttonPairState ;
480
- const buttons = [ bpState . aBtn , bpState . bBtn , bpState . abBtn ] ;
481
- buttons . forEach ( ( btn , index ) => {
482
- svg . fill ( this . buttons [ index ] , btn . pressed ? theme . buttonDown : theme . buttonUp ) ;
483
- } ) ;
478
+ const { buttonDown , buttonUp , virtualButtonUp } = this . props . theme ;
479
+ const { aBtn , bBtn , abBtn } = state . buttonPairState ;
480
+ svg . fill ( this . buttons [ 0 ] , aBtn . pressed ? buttonDown : buttonUp ) ;
481
+ svg . fill ( this . buttons [ 1 ] , bBtn . pressed ? buttonDown : buttonUp ) ;
482
+ svg . fill ( this . buttons [ 2 ] , abBtn . pressed ? buttonDown : virtualButtonUp ) ;
483
+ svg . fill ( this . headParts , state . logoTouch . pressed ? buttonDown : buttonUp ) ;
484
484
}
485
485
486
486
private updateLEDMatrix ( ) {
@@ -530,9 +530,15 @@ path.sim-board {
530
530
svg . fill ( this . shakeButton , this . props . theme . virtualButtonUp ) ;
531
531
this . board . accelerometerState . shake ( ) ;
532
532
} )
533
- accessibility . enableKeyboardInteraction ( this . shakeButton , undefined , ( ) => {
534
- this . board . accelerometerState . shake ( ) ;
535
- } ) ;
533
+ accessibility . enableKeyboardInteraction ( this . shakeButton ,
534
+ ( ) => { // keydown
535
+ svg . fill ( this . shakeButton , this . props . theme . buttonDown ) ;
536
+ } ,
537
+ ( ) => { // keyup
538
+ svg . fill ( this . shakeButton , this . props . theme . virtualButtonUp ) ;
539
+ this . board . accelerometerState . shake ( ) ;
540
+ }
541
+ ) ;
536
542
accessibility . setAria ( this . shakeButton , "button" , "Shake the board" ) ;
537
543
this . shakeText = svg . child ( this . g , "text" , { x : 420 , y : 122 , class : "sim-text-small" } ) as SVGTextElement ;
538
544
this . shakeText . textContent = "SHAKE" ;
@@ -1507,12 +1513,25 @@ path.sim-board {
1507
1513
this . board . bus . queue ( state . edgeConnectorState . pins [ index ] . id , DAL . MICROBIT_BUTTON_EVT_CLICK ) ;
1508
1514
pressedTime = undefined ;
1509
1515
} )
1510
- accessibility . enableKeyboardInteraction ( btn , undefined , ( ) => {
1511
- let state = this . board ;
1512
- this . board . bus . queue ( state . edgeConnectorState . pins [ index ] . id , DAL . MICROBIT_BUTTON_EVT_DOWN ) ;
1513
- this . board . bus . queue ( state . edgeConnectorState . pins [ index ] . id , DAL . MICROBIT_BUTTON_EVT_UP ) ;
1514
- this . board . bus . queue ( state . edgeConnectorState . pins [ index ] . id , DAL . MICROBIT_BUTTON_EVT_CLICK ) ;
1515
- } ) ;
1516
+ accessibility . enableKeyboardInteraction ( btn ,
1517
+ ( ) => { // keydown
1518
+ let state = this . board ;
1519
+ state . edgeConnectorState . pins [ index ] . touched = true ;
1520
+ let svgpin = this . pins [ index ] ;
1521
+ U . addClass ( svgpin , "touched" ) ;
1522
+ this . updatePin ( state . edgeConnectorState . pins [ index ] , index ) ;
1523
+ this . board . bus . queue ( state . edgeConnectorState . pins [ index ] . id , DAL . MICROBIT_BUTTON_EVT_DOWN ) ;
1524
+ } ,
1525
+ ( ) => { // keyup
1526
+ let state = this . board ;
1527
+ state . edgeConnectorState . pins [ index ] . touched = false ;
1528
+ let svgpin = this . pins [ index ] ;
1529
+ U . removeClass ( svgpin , "touched" ) ;
1530
+ this . updatePin ( state . edgeConnectorState . pins [ index ] , index ) ;
1531
+ this . board . bus . queue ( state . edgeConnectorState . pins [ index ] . id , DAL . MICROBIT_BUTTON_EVT_UP ) ;
1532
+ this . board . bus . queue ( state . edgeConnectorState . pins [ index ] . id , DAL . MICROBIT_BUTTON_EVT_CLICK ) ;
1533
+ }
1534
+ ) ;
1516
1535
} )
1517
1536
}
1518
1537
@@ -1530,19 +1549,19 @@ path.sim-board {
1530
1549
attachButtonEvents ( stateButton : Button , buttonOuter : SVGElement , elButton : SVGElement ) {
1531
1550
let pressedTime : number ;
1532
1551
pointerEvents . down . forEach ( evid => buttonOuter . addEventListener ( evid , ev => {
1533
- // console.log(`down ${stateButton.id}`)
1534
1552
stateButton . pressed = true ;
1535
- svg . fill ( elButton , this . props . theme . buttonDown ) ;
1553
+ this . updateButtonPairs ( ) ;
1536
1554
this . board . bus . queue ( stateButton . id , DAL . MICROBIT_BUTTON_EVT_DOWN ) ;
1537
1555
pressedTime = runtime . runningTime ( )
1538
1556
} ) ) ;
1539
1557
buttonOuter . addEventListener ( pointerEvents . leave , ev => {
1540
1558
stateButton . pressed = false ;
1559
+ this . updateButtonPairs ( ) ;
1541
1560
svg . fill ( elButton , this . props . theme . buttonUp ) ;
1542
1561
} )
1543
1562
buttonOuter . addEventListener ( pointerEvents . up , ev => {
1544
1563
stateButton . pressed = false ;
1545
- svg . fill ( elButton , this . props . theme . buttonUp ) ;
1564
+ this . updateButtonPairs ( ) ;
1546
1565
this . board . bus . queue ( stateButton . id , DAL . MICROBIT_BUTTON_EVT_UP ) ;
1547
1566
const currentTime = runtime . runningTime ( )
1548
1567
if ( currentTime - pressedTime > DAL . DEVICE_BUTTON_LONG_CLICK_TIME )
@@ -1551,10 +1570,16 @@ path.sim-board {
1551
1570
this . board . bus . queue ( stateButton . id , DAL . MICROBIT_BUTTON_EVT_CLICK ) ;
1552
1571
pressedTime = undefined ;
1553
1572
} )
1554
- accessibility . enableKeyboardInteraction ( buttonOuter , undefined , ( ) => {
1555
- this . board . bus . queue ( stateButton . id , DAL . MICROBIT_BUTTON_EVT_DOWN ) ;
1556
- this . board . bus . queue ( stateButton . id , DAL . MICROBIT_BUTTON_EVT_UP ) ;
1557
- this . board . bus . queue ( stateButton . id , DAL . MICROBIT_BUTTON_EVT_CLICK ) ;
1573
+ accessibility . enableKeyboardInteraction ( buttonOuter ,
1574
+ ( ) => { // keydown
1575
+ stateButton . pressed = true ;
1576
+ this . updateButtonPairs ( ) ;
1577
+ this . board . bus . queue ( stateButton . id , DAL . MICROBIT_BUTTON_EVT_DOWN ) ;
1578
+ } , ( ) => { // keyup
1579
+ stateButton . pressed = false ;
1580
+ this . updateButtonPairs ( ) ;
1581
+ this . board . bus . queue ( stateButton . id , DAL . MICROBIT_BUTTON_EVT_UP ) ;
1582
+ this . board . bus . queue ( stateButton . id , DAL . MICROBIT_BUTTON_EVT_CLICK ) ;
1558
1583
} ) ;
1559
1584
}
1560
1585
@@ -1567,27 +1592,21 @@ path.sim-board {
1567
1592
bpState . aBtn . pressed = true ;
1568
1593
bpState . bBtn . pressed = true ;
1569
1594
bpState . abBtn . pressed = true ;
1570
- svg . fill ( this . buttons [ 0 ] , this . props . theme . buttonDown ) ;
1571
- svg . fill ( this . buttons [ 1 ] , this . props . theme . buttonDown ) ;
1572
- svg . fill ( this . buttons [ 2 ] , this . props . theme . buttonDown ) ;
1595
+ this . updateButtonPairs ( ) ;
1573
1596
this . board . bus . queue ( bpState . abBtn . id , DAL . MICROBIT_BUTTON_EVT_DOWN ) ;
1574
1597
pressedTime = runtime . runningTime ( )
1575
1598
} ) ) ;
1576
1599
this . buttonsOuter [ 2 ] . addEventListener ( pointerEvents . leave , ev => {
1577
1600
bpState . aBtn . pressed = false ;
1578
1601
bpState . bBtn . pressed = false ;
1579
1602
bpState . abBtn . pressed = false ;
1580
- svg . fill ( this . buttons [ 0 ] , this . props . theme . buttonUp ) ;
1581
- svg . fill ( this . buttons [ 1 ] , this . props . theme . buttonUp ) ;
1582
- svg . fill ( this . buttons [ 2 ] , this . props . theme . virtualButtonUp ) ;
1603
+ this . updateButtonPairs ( ) ;
1583
1604
} )
1584
1605
this . buttonsOuter [ 2 ] . addEventListener ( pointerEvents . up , ev => {
1585
1606
bpState . aBtn . pressed = false ;
1586
1607
bpState . bBtn . pressed = false ;
1587
1608
bpState . abBtn . pressed = false ;
1588
- svg . fill ( this . buttons [ 0 ] , this . props . theme . buttonUp ) ;
1589
- svg . fill ( this . buttons [ 1 ] , this . props . theme . buttonUp ) ;
1590
- svg . fill ( this . buttons [ 2 ] , this . props . theme . virtualButtonUp ) ;
1609
+ this . updateButtonPairs ( ) ;
1591
1610
1592
1611
this . board . bus . queue ( bpState . abBtn . id , DAL . MICROBIT_BUTTON_EVT_UP ) ;
1593
1612
const currentTime = runtime . runningTime ( )
@@ -1596,12 +1615,24 @@ path.sim-board {
1596
1615
else
1597
1616
this . board . bus . queue ( bpState . abBtn . id , DAL . MICROBIT_BUTTON_EVT_CLICK ) ;
1598
1617
pressedTime = undefined ;
1599
- } )
1600
- accessibility . enableKeyboardInteraction ( this . buttonsOuter [ 2 ] , undefined , ( ) => {
1601
- this . board . bus . queue ( bpState . abBtn . id , DAL . MICROBIT_BUTTON_EVT_DOWN ) ;
1602
- this . board . bus . queue ( bpState . abBtn . id , DAL . MICROBIT_BUTTON_EVT_UP ) ;
1603
- this . board . bus . queue ( bpState . abBtn . id , DAL . MICROBIT_BUTTON_EVT_CLICK ) ;
1604
1618
} ) ;
1619
+
1620
+ accessibility . enableKeyboardInteraction ( this . buttonsOuter [ 2 ] ,
1621
+ ( ) => { // keydown
1622
+ bpState . aBtn . pressed = true ;
1623
+ bpState . bBtn . pressed = true ;
1624
+ bpState . abBtn . pressed = true ;
1625
+ this . updateButtonPairs ( ) ;
1626
+ this . board . bus . queue ( bpState . abBtn . id , DAL . MICROBIT_BUTTON_EVT_DOWN ) ;
1627
+ } , ( ) => { // keyup
1628
+ bpState . aBtn . pressed = false ;
1629
+ bpState . bBtn . pressed = false ;
1630
+ bpState . abBtn . pressed = false ;
1631
+ this . updateButtonPairs ( ) ;
1632
+ this . board . bus . queue ( bpState . abBtn . id , DAL . MICROBIT_BUTTON_EVT_UP ) ;
1633
+ this . board . bus . queue ( bpState . abBtn . id , DAL . MICROBIT_BUTTON_EVT_CLICK ) ;
1634
+ }
1635
+ ) ;
1605
1636
}
1606
1637
1607
1638
private attachKeyboardEvents ( ) {
0 commit comments