Mouse click position with SystemTrayIconComponent


The SystemTrayIconComponent gives 0,0 as the mouse event position on mouseDown / mouseUp. handleTaskBarEvent could easily find out where the mouse event occured:

POINT point;

Point<float> p((float) point.x, (float) point.y);

const Time eventTime (getMouseEventTime());

const MouseEvent e (Desktop::getInstance().getMainMouseSource(),
                    p, eventMods, &owner, &owner, eventTime,
                    p, eventTime, 1, false);

The position could be used to show a custom component directly above the tray icon.

Could this be added to JUCE?


No.. the mouse-position that goes in that structure is supposed to be a relative position, but since I think it's impossible to get the relative position, then passing the screen coords would just be confusing. If you want to get the screen coords in your handler method, then you can easily just get them yourself from Desktop::getMousePosition(), they don't need to be passed in.


That makes sense. Your approach works just as well and is much cleaner. I just tried it and it works like a charm. Thanks!