Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!rosie!aozer From: aozer@next.com (Ali Ozer) Newsgroups: comp.sys.next Subject: Re: obtaining current mouse pointer location Keywords: mouse Message-ID: <334@rosie.NeXT.COM> Date: 24 Feb 91 19:44:23 GMT References: <1128@nada.cs.utexas.edu> Sender: news@NeXT.COM Organization: Next Computer, Inc. Lines: 38 Nntp-Posting-Host: twinpeaks.next.com In article <1128@nada.cs.utexas.edu> John William Garnett writes: >What is the simplest way to determine the current location of the mouse >pointer? ... >I was thinking that PScurrentmouse() was what I needed but every attempt >I make at using it gives me a Bus error. Help! To be able to get the mouse location you need to have a connection to the window server. Typically applications get a connection to the window server when they are created, in the [Application new] call. Thus inserting an [Application new] at the beginning of the program will probably solve your problem. Or, using the dpsclient library, you can create a connection to the window server without instantiating an Application object, as the following example shows: #import #import main () { int done; DPSSetContext(DPSCreateContext(NULL, NULL, NULL, NULL)); do { float x, y; PScurrentmouse (0, &x, &y); printf ("%d, %d\n", (int)x, (int)y); PSbuttondown (&done); } while (!done); } This approach might be good enough for just getting the mouse location, however, it is not recommended if you wish to do any significant communications with the server. Other than the tiny overhead in creating an Application object, using the kit won't slow you down any, and also trying to use a raw dpsclient connection without the kit's error handling, event, and drawing layers will be painful & messy. You're also likely to create programs that don't play nicely with other apps. Ali, Ali_Ozer@NeXT.com Brought to you by Super Global Mega Corp .com