From 4b6275d2e0b40bce8f4644d6d38a63580e84158d Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sun, 14 Apr 2024 23:50:00 +0200 Subject: [PATCH] Fix mouse detection --- src/API/API.ts | 11 ++++++++++- src/API/Mouse.ts | 6 ------ src/API/Randomness.ts | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/API/API.ts b/src/API/API.ts index 70f5331..74a42fd 100644 --- a/src/API/API.ts +++ b/src/API/API.ts @@ -228,6 +228,8 @@ export class UserAPI { scope: (config: OscilloscopeConfig) => void; randI: any; rand: any; + ir: any; + r: any; seed: any; localSeededRandom: any; clearLocalSeed: any; @@ -282,7 +284,6 @@ export class UserAPI { this.bpb = Transport.bpb(this.app); this.ppqn = Transport.ppqn(this.app); this.time_signature = Transport.time_signature(this.app); - this.onMouseMove = Mouse.onmousemove(this.app); this.mouseX = Mouse.mouseX(this.app); this.mouseY = Mouse.mouseY(this.app); this.noteX = Mouse.noteX(this.app); @@ -399,7 +400,9 @@ export class UserAPI { this.gif = Canvas.gif(this.app); this.scope = Canvas.scope(this.app); this.randI = Randomness.randI(this); + this.ir = this.randI; this.rand = Randomness.rand(this); + this.r = this.rand; this.seed = Randomness.seed(this); this.localSeededRandom = Randomness.localSeededRandom(this); this.clearLocalSeed = Randomness.clearLocalSeed(this); @@ -610,4 +613,10 @@ export class UserAPI { functionName = typeof functionName === "function" ? functionName.name : functionName; this.cueTimes[functionName] = this.app.clock.pulses_since_origin; }; + + + onmousemove = (e: MouseEvent) => { + this.app._mouseX = e.pageX; + this.app._mouseY = e.pageY; + }; } diff --git a/src/API/Mouse.ts b/src/API/Mouse.ts index 0acbfa4..b69ef49 100644 --- a/src/API/Mouse.ts +++ b/src/API/Mouse.ts @@ -1,11 +1,5 @@ import { Editor } from "../main"; -// mouse.ts -export const onmousemove = (app: Editor) => (e: MouseEvent): void => { - app._mouseX = e.pageX; - app._mouseY = e.pageY; -}; - export const mouseX = (app: Editor) => (): number => { /** * @returns The current x position of the mouse diff --git a/src/API/Randomness.ts b/src/API/Randomness.ts index 9f02aac..dcf7653 100644 --- a/src/API/Randomness.ts +++ b/src/API/Randomness.ts @@ -8,6 +8,7 @@ export const randI = (api: UserAPI) => (min: number, max: number): number => { export const rand = (api: UserAPI) => (min: number, max: number): number => { return api.randomGen() * (max - min) + min; }; +export const r = rand export const seed = (api: UserAPI) => (seed: string | number): void => { if (typeof seed === "number") seed = seed.toString();