lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
43 lines • 1.48 kB
JavaScript
import { PointerEvent } from './PointerEvent.js';
/**
* A {@link PointerEvent} for button presses/releases, containing helpers for
* checking whether it was the left/primary button, right/secondary button or
* middle/tertiary button. Always take the button ID into account when handling
* this event as you get a pair of {@link PointerPressEvent} and
* {@link PointerReleaseEvent} events per button ID.
*
* Has a focus type decided by the child classes and does not need focus.
*
* @category Event
*/
export class PointerButtonEvent extends PointerEvent {
constructor(x, y, button, shift, ctrl, alt, source, target = null) {
super(x, y, shift, ctrl, alt, source, target);
this.button = button;
}
/** Is the button affected the left/primary button? */
get isLeft() {
return this.button === 0;
}
/** Alias for {@link PointerButtonEvent#isLeft} */
get isPrimary() {
return this.isLeft;
}
/** Is the button affected the right/secondary button? */
get isRight() {
return this.button === 1;
}
/** Alias for {@link PointerButtonEvent#isRight} */
get isSecondary() {
return this.isRight;
}
/** Is the button affected the middle/tertiary button? */
get isMiddle() {
return this.button === 2;
}
/** Alias for {@link PointerButtonEvent#isMiddle} */
get isTertiary() {
return this.isMiddle;
}
}
//# sourceMappingURL=PointerButtonEvent.js.map