View Full Version : Querying the coordinates of the mouse on the screen?
01-27-2004, 02:28 AM
The topic says it all. Is it possible to get mel to retrieve the screen coordinates of the mouse pointer so that it can be fed into a script?
(this is part of a larger issue, whose thread is here, if you're interested: http://www.cgtalk.com/showthread.php?s=&postid=1106410#post1106410 )
01-27-2004, 04:43 AM
no it can't be done through mel alone. i looked into doing something similar quite awhile ago. someone has written a plugin that supplies a mel command that returns screen coordinates, but i've never used it myself.
do a search on highend for the plugin.
hopefully maya 6 will let you do that with mel. :) here to hoping...
01-27-2004, 04:46 AM
Thanks for the reply, Macaroni... sad to hear this can't be done. (yet)
Alternately, it would help if I could force the cursor to appear at a certain position... I don't suppose that's likely either... hm...
01-27-2004, 04:47 AM
Alternately, it would help if I could force the cursor to appear at a certain position... I don't suppose that's likely either... hm...yeah, i expect its even more unlikely to be able to do that. bummer hey...
01-27-2004, 02:02 PM
not a 100% solution, but at least one. directly from maya help.
global proc sampleContextPress()
float $pressPosition = `draggerContext -query -anchorPoint sampleContext`;
print ("Press: " + $pressPosition + " " + $pressPosition + " "
+ $pressPosition + "\n");
global proc sampleContextDrag()
float $dragPosition = `draggerContext -query -dragPoint sampleContext`;
int $button = `draggerContext -query -button sampleContext`;
string $modifier = `draggerContext -query -modifier sampleContext`;
print ("Drag: " + $dragPosition + " " + $dragPosition + " "
+ " Button is " + $button + " Modifier is " + $modifier + "\n");
string $message = ($dragPosition + ", " + $dragPosition);
draggerContext -edit -drawString $message sampleContext;
01-27-2004, 08:07 PM
Thanks Alexx... I'll give that a whirl!
Incidentally, is there some other way I should go about searching for answers with things like this? I looked all over the MEL reference for "mouse" or "pointer" or "cursor", but it never would have occurred to me to look up "dragger."
Is this just something you learn by virtue of being around MEL for longer and longer?
Thanks again! :)
01-28-2004, 08:31 AM
i was looking for some mouse input for a very long time myself and this draggerCtx was the hint of someone else..
i did not find it in the help files myself, since i was looking for the exact same keywords then :)
btw: the "dragger" might be the problem here, because this only seems to work, when the mouse is dragged :/
01-17-2006, 07:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.