@@ -1346,30 +1346,50 @@ namespace microgui {
13461346
13471347 control . onEvent ( ControllerButtonEvent . Pressed , controller . A . id , ( ) => {
13481348 this . btns [ this . selectedTextBtnIndex ] . click ( ) ;
1349- } )
1349+ } ) ;
13501350
13511351 control . onEvent ( ControllerButtonEvent . Pressed , controller . up . id , ( ) => {
1352- this . btns [ this . selectedTextBtnIndex ] . setSelected ( false )
1352+ let tick = true ;
1353+ control . onEvent (
1354+ ControllerButtonEvent . Released ,
1355+ controller . up . id ,
1356+ ( ) => tick = false
1357+ )
13531358
1354- const len = this . btns . length
1355- this . selectedTextBtnIndex = ( ( ( this . selectedTextBtnIndex - 1 ) % len ) + len ) % len
1359+ // Control logic:
1360+ while ( tick ) {
1361+ this . btns [ this . selectedTextBtnIndex ] . setSelected ( false ) ;
1362+ const len = this . btns . length
1363+ this . selectedTextBtnIndex = ( ( ( this . selectedTextBtnIndex - 1 ) % len ) + len ) % len
1364+
1365+ this . btns [ this . selectedTextBtnIndex ] . setSelected ( true )
1366+ basic . pause ( 100 ) // tick rate
1367+ }
1368+
1369+ // Reset binding
1370+ control . onEvent ( ControllerButtonEvent . Released , controller . up . id , ( ) => { } ) ;
1371+ } ) ;
13561372
1357- this . btns [ this . selectedTextBtnIndex ] . setSelected ( true )
1358- } )
13591373
13601374 control . onEvent ( ControllerButtonEvent . Pressed , controller . down . id , ( ) => {
1361- this . btns [ this . selectedTextBtnIndex ] . setSelected ( false )
1362- this . selectedTextBtnIndex = ( this . selectedTextBtnIndex + 1 ) % this . btns . length
1363- this . btns [ this . selectedTextBtnIndex ] . setSelected ( true )
1364- } )
1375+ let tick = true ;
1376+ control . onEvent (
1377+ ControllerButtonEvent . Released ,
1378+ controller . down . id ,
1379+ ( ) => tick = false
1380+ )
13651381
1366- control . onEvent ( ControllerButtonEvent . Pressed , controller . left . id , ( ) => {
1367- this . selectedTextBtnIndex = 0 ;
1368- } )
1382+ // Control logic:
1383+ while ( tick ) {
1384+ this . btns [ this . selectedTextBtnIndex ] . setSelected ( false )
1385+ this . selectedTextBtnIndex = ( this . selectedTextBtnIndex + 1 ) % this . btns . length
1386+ this . btns [ this . selectedTextBtnIndex ] . setSelected ( true )
1387+ basic . pause ( 100 ) // tick rate
1388+ }
13691389
1370- control . onEvent ( ControllerButtonEvent . Pressed , controller . right . id , ( ) => {
1371- this . selectedTextBtnIndex = this . btns . length - 1 ;
1372- } )
1390+ // Reset binding
1391+ control . onEvent ( ControllerButtonEvent . Released , controller . down . id , ( ) => { } ) ;
1392+ } ) ;
13731393 }
13741394
13751395 draw ( ) {
0 commit comments