Skip to content

Commit d049a4e

Browse files
committed
inputMethods.ts: keyboard: defaultText -> defaultTxt, fixed test.ts
1 parent f078ddd commit d049a4e

2 files changed

Lines changed: 42 additions & 39 deletions

File tree

inputMethods.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,14 @@ namespace microgui {
343343
cb: (keyboardText: string) => void,
344344
foregroundColor?: number,
345345
backgroundColor?: number,
346-
defaultText?: string,
346+
defaultTxt?: string,
347347
maxTxtLength?: number,
348348
txtColor?: number,
349349
deleteFn?: () => void,
350350
backBtn?: () => void
351351
}) {
352352
super(opts.app, new GridNavigator([[]])) // GridNavigator setup in startup()
353-
this.text = (opts.defaultText) ? opts.defaultText : ""
353+
this.text = (opts.defaultTxt) ? opts.defaultTxt : ""
354354
this.isUpperCase = true
355355
this.maxTxtLength = (opts.maxTxtLength) ? Math.min(opts.maxTxtLength, this.MAX_TEXT_LENGTH) : this.MAX_TEXT_LENGTH
356356

test.ts

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ namespace microcode {
2222

2323
// Comment out the examples you aren't using:
2424

25+
// Example 0:
2526
const kb = new microgui.Keyboard({
2627
app,
2728
layout: microgui.KeyboardLayouts.NUMERIC,
2829
cb: (txt: string) => { basic.showString(txt) },
2930
foregroundColor: 2, // optional arg
3031
backgroundColor: 6, // optional arg
32+
defaultTxt: "0", // optional arg
3133
maxTxtLength: 6, // optional arg
3234
txtColor: 1, // optional arg
3335
deleteFn: () => { basic.showString("Bye") } // optional arg
@@ -36,7 +38,6 @@ namespace microcode {
3638
app.popScene();
3739
app.pushScene(kb);
3840

39-
4041
// Example 1a:
4142

4243
// const simpleTextComponent = new TextBox({
@@ -135,44 +136,46 @@ namespace microcode {
135136
// app.pushScene(gcs)
136137

137138

138-
const buttonCollection = new ButtonCollection({
139-
alignment: GUIComponentAlignment.TOP,
140-
btns: [
141-
[ // Row 1:
142-
new Button({ icon: "accelerometer", ariaId: "0", onClick: () => basic.showNumber(0) }),
143-
new Button({ icon: "pin_0", ariaId: "1", onClick: () => basic.showNumber(1) }),
144-
new Button({ icon: "pin_1", ariaId: "2", onClick: () => basic.showNumber(2) }),
145-
new Button({ icon: "pin_2", ariaId: "3", onClick: () => basic.showNumber(3) }),
146-
],
147-
[ // Row 2:
148-
new Button({ icon: "thermometer", ariaId: "4", onClick: () => basic.showNumber(4) }),
149-
new Button({ icon: "microphone", ariaId: "5", onClick: () => basic.showNumber(5) })
150-
],
151-
[ // Row 3:
152-
new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
153-
new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
154-
new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
155-
new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
156-
new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
157-
158-
],
159-
[ // Row 4:
160-
new Button({ icon: "right_spin", ariaId: "7", onClick: () => basic.showNumber(7) }),
161-
new Button({ icon: "right_turn", ariaId: "8", onClick: () => basic.showNumber(8) }),
162-
new Button({ icon: "green_tick", ariaId: "9", onClick: () => basic.showNumber(9) })
163-
],
164-
],
165-
isActive: true,
166-
isHidden: false,
167-
xScaling: 1.1,
168-
yScaling: 1.7,
169-
colour: 3,
170-
})
171-
172-
const gcs = new GUIComponentScene({ app, components: [buttonCollection] })
173-
app.pushScene(gcs)
174139

175140

141+
142+
// const buttonCollection = new ButtonCollection({
143+
// alignment: GUIComponentAlignment.TOP,
144+
// btns: [
145+
// [ // Row 1:
146+
// new Button({ icon: "accelerometer", ariaId: "0", onClick: () => basic.showNumber(0) }),
147+
// new Button({ icon: "pin_0", ariaId: "1", onClick: () => basic.showNumber(1) }),
148+
// new Button({ icon: "pin_1", ariaId: "2", onClick: () => basic.showNumber(2) }),
149+
// new Button({ icon: "pin_2", ariaId: "3", onClick: () => basic.showNumber(3) }),
150+
// ],
151+
// [ // Row 2:
152+
// new Button({ icon: "thermometer", ariaId: "4", onClick: () => basic.showNumber(4) }),
153+
// new Button({ icon: "microphone", ariaId: "5", onClick: () => basic.showNumber(5) })
154+
// ],
155+
// [ // Row 3:
156+
// new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
157+
// new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
158+
// new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
159+
// new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
160+
// new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
161+
162+
// ],
163+
// [ // Row 4:
164+
// new Button({ icon: "right_spin", ariaId: "7", onClick: () => basic.showNumber(7) }),
165+
// new Button({ icon: "right_turn", ariaId: "8", onClick: () => basic.showNumber(8) }),
166+
// new Button({ icon: "green_tick", ariaId: "9", onClick: () => basic.showNumber(9) })
167+
// ],
168+
// ],
169+
// isActive: true,
170+
// isHidden: false,
171+
// xScaling: 1.1,
172+
// yScaling: 1.7,
173+
// colour: 3,
174+
// })
175+
176+
// const gcs = new GUIComponentScene({ app, components: [buttonCollection] })
177+
// app.pushScene(gcs)
178+
176179

177180
// Example 4: Component context: Linking a graph with a button:
178181

0 commit comments

Comments
 (0)