How can I get the screen position of the DockTile in OSX?

谁说我不能喝 提交于 2019-12-02 08:33:29

问题


I need a window to 'point' to the icon that was clicked on in the dock, similar to the way the context menu has the little callout-arrow pointing to it. This means I need to get the screen location of the dock, or more accurately the DockTile. (Yes I could use the mouse coordinates, but that doesn't look as good as it 'moves'.)

Now my thought is to get the associated view (I already have that), then use view-to-screen coordinate conversions, but that's becoming problematic as the x/left and y/top values of the bounding rectangle always say zero. I know that's because there's a nested hierarchy of views as well. Problem is I've walked it and always end up hitting a road block.

So thoughts?

Mark


回答1:


You can get the dock icon positions using the accessibility API, there's some excellent sample code and app from Apple here.



来源:https://stackoverflow.com/questions/5494079/how-can-i-get-the-screen-position-of-the-docktile-in-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!