Skip to content

Commit d451235

Browse files
committed
Fixed RadioButton auto placement
1 parent 988250d commit d451235

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

guiComponents.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ namespace microgui {
11651165
private onClick: (obj?: Object) => void;
11661166
private isSelected: boolean;
11671167

1168-
constructor(opts: { text: string, onClick: (obj: Object) => void, colour?: number}) {
1168+
constructor(opts: { text: string, onClick: (obj: Object) => void, colour?: number }) {
11691169
this.text = opts.text;
11701170
this.x = null;
11711171
this.y = null;
@@ -1245,8 +1245,8 @@ namespace microgui {
12451245

12461246
for (let i = 0; i < this.btns.length; i++) {
12471247
this.btns[i].setPosition(
1248-
xBorder + this.bounds.left + this.bounds.width,
1249-
((i + 1) * ySpacing)
1248+
xBorder + this.bounds.left + this.bounds.width,
1249+
this.bounds.top + this.bounds.height + ((i + 1) * ySpacing) - 3
12501250
);
12511251
this.btns[i].setSelected(false)
12521252
}
@@ -1462,7 +1462,7 @@ namespace microgui {
14621462
const btn = row[j]
14631463
if (autoScaling && btn.xfrm.localPos.x == 0)
14641464
btn.xfrm.localPos.x = this.bounds.left + ((j + 1) * xSpacing) - (xBorder >> 1)
1465-
else
1465+
else
14661466
btn.xfrm.localPos.x = this.bounds.left + btn.xfrm.localPos.x + (btn.width >> 1)
14671467
if (autoScaling && btn.xfrm.localPos.y == 0)
14681468
btn.xfrm.localPos.y = this.bounds.top + ((i + 1) * ySpacing) - (yBorder >> 1)

main.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
2-
31
namespace microcode {
4-
import App = microgui.App
52
import Scene = user_interface_base.Scene
63
import SceneManager = user_interface_base.SceneManager
74
import Screen = user_interface_base.Screen
8-
import KeyboardMenu = microgui.KeyboardMenu
95
import Button = user_interface_base.Button
6+
7+
import App = microgui.App
8+
import KeyboardMenu = microgui.KeyboardMenu
109
import ButtonCollection = microgui.ButtonCollection
1110
import GUIComponentAlignment = microgui.GUIComponentAlignment
1211
import TextBox = microgui.TextBox
@@ -18,10 +17,10 @@ namespace microcode {
1817
import RadioButtonCollection = microgui.RadioButtonCollection
1918
import RadioButton = microgui.RadioButton
2019

20+
2121
control.singleSimulator();
2222
const app = new App();
2323

24-
2524
// Comment out the examples you aren't using:
2625

2726

@@ -142,7 +141,7 @@ namespace microcode {
142141
new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
143142
new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
144143
new Button({ icon: "compass", ariaId: "6", onClick: () => basic.showNumber(6) }),
145-
144+
146145
],
147146
[ // Row 4:
148147
new Button({ icon: "right_spin", ariaId: "7", onClick: () => basic.showNumber(7) }),
@@ -217,16 +216,16 @@ namespace microcode {
217216
// Example 6: RadioButtons
218217

219218
// const rbc = new RadioButtonCollection({
220-
// alignment: GUIComponentAlignment.TOP,
219+
// alignment: GUIComponentAlignment.BOT,
221220
// btns: [
222-
// new RadioButton({ text: "hi", onClick: () => { basic.showString("hi") } }),
223-
// new RadioButton({ text: "hiya", onClick: () => { basic.showString("hiya") } }),
224-
// new RadioButton({ text: "hello", onClick: () => { basic.showString("hello") } }),
225-
// new RadioButton({ text: "hello", onClick: () => { basic.showString("hello") } })
221+
// new RadioButton({ text: "hi", onClick: () => { basic.showString("a") } }),
222+
// new RadioButton({ text: "hiya", onClick: () => { basic.showString("b") } }),
223+
// new RadioButton({ text: "hello", onClick: () => { basic.showString("c") } }),
224+
// new RadioButton({ text: "howdy", onClick: () => { basic.showString("d") } })
226225
// ],
227226
// isActive: true,
228227
// yScaling: 1.1,
229-
// // title: "The title",
228+
// title: "The title",
230229
// colour: 3,
231230
// })
232231

0 commit comments

Comments
 (0)