daveg@Apple.COM (David Green) (10/02/89)
I'm having trouble using GlobalToLocal in a simple desk Accessory I'm writing.
Upon getting the mousedown event, I set the port to that in the eventMessage.
(hopefully the DA's port, is this always true?)
At this point I drop into Macsbug and view the point in the
eventRecord's Where field. It is in Global coordinates as I tested it out
moving the window around and checking the various values.
I then pass this point to GlobalToLocal and it comes back garbaged.
Has anyone had troubles with Global to local before? This seems trivial, but
I have been away from coding so long that it is stumping me.
Here is the code that processes the event:
if (theEvent->what == mouseDown) {
myWindow = (WindowPtr) theEvent->message;
SetPort(myWindow); /* use the port of the DA */
foo = theEvent->where;
Debugger();
GlobalToLocal(&foo); /* convert to local axes */
Debugger();
if (PtInRect(foo,&globals->listBox)) SysBeep(1);
Thanks much for any help in advance. This problem seems so straightforward
that I am having trouble seeing it. Frustration is quickly settling in....
Dave
--
Disclaimer: The above is all me and has no correlation to Apple policy.
******************************************************************************
* * *
* Dave Green * Scratch that, reverse it. *
* daveg@Apple.com * Willie W *
* * *
******************************************************************************kazim@Apple.COM (Alex Kazim) (10/02/89)
In article <35161@apple.Apple.COM> daveg@apple.com (David Green) writes: > >Upon getting the mousedown event, I set the port to that in the eventMessage. >(hopefully the DA's port, is this always true?) > Ah, the age old problem of finding the target window from the event record. I don't think event.message is defined for mousedown and you need to call: part := FindWindow(event.where, window) which will return the window, and part = inSysWindow for you DA. winodw := event.message works for activate & update events. Hope this helps... =================================================================== Alex Kazim, Apple Computer Phone Repair Man ===================================================================