cursor position in windows XP

Mar 12, 2008 at 10:16am

cursor position in windows XP

hallo everyone,

i am trying to access he mouse position in absolute screen coordinates from within a jsui object. The wind.location property returns the coordinates of the mouse cursor relative to the Left Top of the main Max/MSP application window, not the screen coordinates. The reason i need the absolute screen coordinates is that i want to lock the mouse position while drugging inside the jsui.
Any suggestions ??

__George

#36317
Feb 4, 2009 at 5:03pm

Hello George,

Have you found a solution finally ?

I also faced the same challenge, and for now I’m using mousestate (obviously outside the JSUI). But a solution within the JSUI would be more convenient.

Salvator

#124536
Feb 4, 2009 at 11:37pm

Try adding the [jsui] click co-ordinates to the object box offset to the patcher window offset as illustrated below. It will output the cursor position like [mousestate] in global mode (“0″). I hope it helps.

lh

// abspos.js

function onclick(x,y)
{
var patchpos = this.patcher.wind.location;
var objpos = this.box.rect;
var absx = patchpos[0]+objpos[0]+x;
var absy = patchpos[1]+objpos[1]+y;
outlet(0, absx, absy);
}

// EOF

#124537
Feb 5, 2009 at 9:24pm

it works, thanks !!!
I love max forum :-)

Salvator

#124538
Feb 5, 2009 at 10:31pm

#124539

You must be logged in to reply to this topic.