开发者

Position of window in Cocoa

i have simple question: How to get position of window on screen in cocoa? I try using frame from NSWindow but in result i have x and y of window always 0, but my win开发者_C百科dow isn't on this position.

Best regards Chudziutki


How to get position of window on screen in cocoa?

Send it a frame message and look at the result's origin member.

I try using frame from NSWindow but in result i have x and y of window always 0, but my window isn't on this position.

You forgot to hook up the outlet to your window, so you're sending that frame message to nil.

Frankly, it's surprising that the frame rectangle makes any sense at all instead of being a geometrically-impossible random set of numbers. Messages to nil return 0 for scalar types, such as pointers and single numbers, but a message that returns a structure (such as a rectangle) is not guaranteed to return anything.

Or you're talking to the wrong window—perhaps you created one in a nib and then created another one in code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜