Skip navigation.
 
mlRe: howto get global mouse states
FROM : Sean McBride
DATE : Mon Oct 04 18:58:03 2004

Christian Robl (<email_removed>) on Mon, Oct 4, 2004 06:34 said:

>I want to build a COCOA application wich should recenter its window on the
>current mouseposition if a particular mouse button is pressed (e.g. middle
>button).


First, I have to say that's a pretty weird thing to do, but I'll give you
the benefit of the doubt that you know what you're doing. :)

>In "awakefromnib" I call [NSEvent mouseLocation] for an initial window
>placement which works great. While running the app I can get some
>informations via polling [NSApp currentEvent] and
>processign according the Event occured, but as soon as I mov/click outside
>of the app's window
>no event occurs or is processed by my app.
>
>Whats wrong?


I guess that's by design.  If a click does not touch any interface
element of your application, then the OS sends the event elsewhere
(perhaps to another app's window that is underneath where you clicked).

>How can I get mouse states regardless if the apps window is
>clicked/active.


I don't know.  Perhaps you could make a big invisible window that covers
the screen(s) and is below all your other windows.  Then, presumably,
that window would get events.  I've never tried though.

Related mailsAuthorDate
mlhowto get global mouse states Christian Robl Oct 4, 12:34
mlRe: howto get global mouse states Sean McBride Oct 4, 18:58
mlRe: howto get global mouse states John C. Randolph Oct 4, 23:38
mlRe: howto get global mouse states Henry McGilton Oct 5, 15:29