Hi,
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 window isn't on this position.
Best regards Chudziutki
Hi,
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 window 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.