Input blocks revision
- add Button and Pin event types - merge onPinPressed & onPinReleased in new onPinEvent function - create new onButtonEvent function
This commit is contained in:
@ -1,4 +1,14 @@
|
||||
namespace pxsim.input {
|
||||
export function onButtonEvent(button: number, buttonEvent: number, handler: RefAction): void {
|
||||
let b = board().buttonPairState;
|
||||
if (button == b.props.ID_BUTTON_AB && !b.usesButtonAB) {
|
||||
b.usesButtonAB = true;
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
pxtcore.registerWithDal(button, buttonEvent, handler);
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
export function onButtonPressed(button: number, handler: RefAction): void {
|
||||
let b = board().buttonPairState;
|
||||
if (button == b.props.ID_BUTTON_AB && !b.usesButtonAB) {
|
||||
|
@ -1,4 +1,13 @@
|
||||
namespace pxsim.input {
|
||||
export function onPinEvent(pinId: number, pinEvent: number, handler: RefAction) {
|
||||
let pin = getPin(pinId);
|
||||
if (!pin) return;
|
||||
pin.isTouched();
|
||||
runtime.queueDisplayUpdate();
|
||||
pxtcore.registerWithDal(pin.id, pinEvent, handler);
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
export function onPinPressed(pinId: number, handler: RefAction) {
|
||||
let pin = getPin(pinId);
|
||||
if (!pin) return;
|
||||
@ -7,6 +16,7 @@ namespace pxsim.input {
|
||||
pxtcore.registerWithDal(pin.id, DAL.MICROBIT_BUTTON_EVT_CLICK, handler);
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
export function onPinReleased(pinId: number, handler: RefAction) {
|
||||
let pin = getPin(pinId);
|
||||
if (!pin) return;
|
||||
|
Reference in New Issue
Block a user