Skip to content

Commit 8829fb9

Browse files
committed
GUISlider: can hold up or down to slide
1 parent 7d15899 commit 8829fb9

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

guiComponents.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,41 @@ namespace microcode {
380380
control.onEvent(
381381
ControllerButtonEvent.Pressed,
382382
controller.up.id,
383-
() => this.context[0] = Math.min(this.context[0] + 10, this.maximum)
383+
() => {
384+
let tick = true;
385+
control.onEvent(
386+
ControllerButtonEvent.Released,
387+
controller.up.id,
388+
() => tick = false
389+
)
390+
391+
// Control logic:
392+
while (tick) {
393+
this.context[0] = Math.min(this.context[0] + 10, this.maximum)
394+
basic.pause(100)
395+
}
396+
control.onEvent(ControllerButtonEvent.Released, controller.up.id, () => { })
397+
}
384398
)
385399

386400
control.onEvent(
387401
ControllerButtonEvent.Pressed,
388402
controller.down.id,
389-
() => this.context[0] = Math.max(this.context[0] - 10, this.minimum)
403+
() => {
404+
let tick = true;
405+
control.onEvent(
406+
ControllerButtonEvent.Released,
407+
controller.down.id,
408+
() => tick = false
409+
)
410+
411+
// Control logic:
412+
while (tick) {
413+
this.context[0] = Math.max(this.context[0] - 10, this.minimum)
414+
basic.pause(100)
415+
}
416+
control.onEvent(ControllerButtonEvent.Released, controller.down.id, () => { })
417+
}
390418
)
391419
}
392420

0 commit comments

Comments
 (0)