osx - Cocoa: get global mouse position at "current event" time -


i know [nsevent mouselocation] gives me current mouse position outside event stream. there way mouse position in screen space @ time of current event (so correlated mouse pos mouse events)? want avoid tracking myself mouse events of windows , storing in global.

thanks.

if understand correctly want, can call [nsapp currentevent] current event, , call [nsevent locationinwindow] on event returned method. give mouse location of current event being processed application, opposed mouse location @ present moment in time, supplied [nsevent mouselocation].

if need convert window-based location screen-based location, can use nsevent method -window window event, , use [window convertrecttoscreen:] convert point screen coordinates. it's little weird have use nsrect-based api; don't understand why apple deprecated convertbasetoscreen:, seemed api. if put window location in origin of nsrect, size of {0,0} using nsmakerect, , use convertrecttoscreen: , extract origin out nspoint, seems convert point fine.


Comments