How can I get the screen position of the DockTile

2019-02-28 01:09发布

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条回答
ゆ 、 Hurt°
2楼-- · 2019-02-28 01:52

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

查看更多
登录 后发表回答