11
22
3+
34//% block="MicroGUI" weight=100, color=#000A83
45namespace microgui {
56 import AppInterface = user_interface_base . AppInterface
@@ -1200,13 +1201,16 @@ namespace microgui {
12001201
12011202 //% block="Radio Button Collection" weight=50, color=#F6FAB4
12021203 export class RadioButtonCollection extends GUIComponentAbstract {
1204+ private static MINIMUM_BUTTON_Y_SPACING : number = 2 ;
1205+
12031206 private title : string ;
12041207 private btns : RadioButton [ ]
12051208 private selectedTextBtnIndex : number ;
12061209
12071210 private xBorder = 12
12081211 private minYBorder = 5 ;
1209- private static MINIMUM_BUTTON_Y_SPACING : number = 2 ;
1212+
1213+ private backBtn : ( ( btn ?: Button ) => void ) | null ;
12101214
12111215 constructor ( opts : {
12121216 alignment : GUIComponentAlignment ,
@@ -1220,7 +1224,8 @@ namespace microgui {
12201224 colour ?: number ,
12211225 border ?: boolean ,
12221226 title ?: string ,
1223- text ?: string | string [ ]
1227+ text ?: string | string [ ] ,
1228+ backBtn ?: ( btn ?: Button ) => void
12241229 } ) {
12251230 super ( {
12261231 alignment : opts . alignment ,
@@ -1258,6 +1263,8 @@ namespace microgui {
12581263 this . btns [ this . selectedTextBtnIndex ] . setSelected ( true )
12591264 } ;
12601265
1266+ this . backBtn = opts . backBtn ? opts . backBtn : null ;
1267+
12611268 super . makeActive ( ) ;
12621269 this . setupButtonBindings ( ) ;
12631270 }
@@ -1302,6 +1309,10 @@ namespace microgui {
13021309 this . btns [ this . selectedTextBtnIndex ] . click ( ) ;
13031310 } )
13041311
1312+ if ( this . backBtn )
1313+ context . onEvent ( ControllerButtonEvent . Pressed , controller . B . id , ( ) => {
1314+ this . backBtn ( ) ;
1315+ } )
13051316
13061317 context . onEvent ( ControllerButtonEvent . Pressed , controller . up . id , ( ) => {
13071318 this . btns [ this . selectedTextBtnIndex ] . setSelected ( false ) ;
@@ -1771,3 +1782,4 @@ namespace microgui {
17711782 }
17721783 }
17731784}
1785+
0 commit comments