1+
12namespace microcode {
23 import Scene = user_interface_base . Scene
34 import SceneManager = user_interface_base . SceneManager
@@ -20,37 +21,58 @@ namespace microcode {
2021 control . singleSimulator ( ) ;
2122 const app = new App ( ) ;
2223
24+ const simpleTextComponent : microgui . GUIComponentAbstract = new TextBox ( {
25+ alignment : GUIComponentAlignment . BOT ,
26+ isActive : false ,
27+ title : "Title Text :)" , // optional arg
28+ text : [ "Press micro:bit A btn" ] , // optional arg
29+ colour : 6 , // optional arg
30+ xScaling : 1.7 , // optional arg
31+ } )
32+
33+
34+ let count = 0 ;
35+ input . onButtonPressed ( 1 , function ( ) {
36+ count ++ ;
37+ simpleTextComponent . clearContext ( )
38+ simpleTextComponent . addContext ( [ "" + count ] )
39+ } )
40+
41+ const gcs = new GUIComponentScene ( { app, components : [ simpleTextComponent ] } )
42+ app . pushScene ( gcs )
43+
2344 // Comment out the examples you aren't using:
2445
2546 // Example 0:
26- const kb = new microgui . Keyboard ( {
27- app,
28- layout : microgui . KeyboardLayouts . NUMERIC ,
29- cb : ( txt : string ) => { basic . showString ( txt ) } ,
30- foregroundColor : 2 , // optional arg
31- backgroundColor : 6 , // optional arg
32- defaultTxt : "0" , // optional arg
33- maxTxtLength : 6 , // optional arg
34- txtColor : 1 , // optional arg
35- deleteFn : ( ) => basic . showString ( "Bye" ) , // optional arg
36- backBtn : ( ) => basic . showNumber ( 2 )
37- } ) ;
38-
39- app . popScene ( ) ;
40- app . pushScene ( kb ) ;
47+ // const kb = new microgui.Keyboard({
48+ // app,
49+ // layout: microgui.KeyboardLayouts.NUMERIC,
50+ // cb: (txt: string) => { basic.showString(txt) },
51+ // foregroundColor: 2, // optional arg
52+ // backgroundColor: 6, // optional arg
53+ // defaultTxt: "0", // optional arg
54+ // maxTxtLength: 6, // optional arg
55+ // txtColor: 1, // optional arg
56+ // deleteFn: () => basic.showString("Bye"), // optional arg
57+ // backBtn: () => basic.showNumber(2)
58+ // });
59+
60+ // app.popScene();
61+ // app.pushScene(kb);
62+
4163 // Example 1a:
4264
43- // const simpleTextComponent = new TextBox({
44- // alignment: GUIComponentAlignment.BOT,
45- // isActive: false,
46- // title: "Title Text :)", // optional arg
47- // text: ["Hello there,", "I hope you are well.", "Isn't this neat?"], // optional arg
48- // colour: 6, // optional arg
49- // xScaling: 1.7, // optional arg
50- // })
65+ // const simpleTextComponent = new TextBox({
66+ // alignment: GUIComponentAlignment.BOT,
67+ // isActive: false,
68+ // title: "Title Text :)", // optional arg
69+ // text: ["Hello there,", "I hope you are well.", "Isn't this neat?"], // optional arg
70+ // colour: 6, // optional arg
71+ // xScaling: 1.7, // optional arg
72+ // })
5173
52- // const gcs = new GUIComponentScene({ app, components: [simpleTextComponent] })
53- // app.pushScene(gcs)
74+ // const gcs = new GUIComponentScene({ app, components: [simpleTextComponent] })
75+ // app.pushScene(gcs)
5476
5577
5678
@@ -138,7 +160,7 @@ namespace microcode {
138160
139161
140162
141-
163+
142164 // const buttonCollection = new ButtonCollection({
143165 // alignment: GUIComponentAlignment.TOP,
144166 // btns: [
@@ -249,3 +271,4 @@ namespace microcode {
249271 // app.pushScene(gcs);
250272}
251273
274+
0 commit comments