Skip to content

Commit 0362c2c

Browse files
authored
Merge pull request #8232 from nbogie/add-mouseButton-types-fix-8231
Fix missing mouseButton property types
2 parents 888a9d0 + 6c39138 commit 0362c2c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

test/types/basic.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,8 @@ function draw() {
7171
rotateY(millis() * 0.0001)
7272
model(geom)
7373
}
74+
75+
function mousePressed(){
76+
//only type-checking the relevant properties exist on the mouseButton object type.
77+
const whatever = mouseButton.left || mouseButton.center || mouseButton.right;
78+
}

utils/patch.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ export function applyPatches() {
116116
'fontBounds(str: string, x: number, y: number, width?: number, height?: number): object;',
117117
'fontBounds(str: string, x: number, y: number, width?: number, height?: number): { x: number; y: number; w: number; h: number };',
118118
);
119+
replace(
120+
'p5.d.ts',
121+
'mouseButton: object;',
122+
'mouseButton: { left: boolean; center: boolean; right: boolean };'
123+
);
119124
replace(
120125
'p5.d.ts',
121126
'textBounds(str: string, x: number, y: number, width?: number, height?: number): object;',

0 commit comments

Comments
 (0)