Is there any way I get get the size of an NSWindow (in pixels) and display it? So when the person resizes the window the text will change and display the new size.
If you implement the method
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize
on an object you set as the delegate of the window, it will be called whenever the window changes size. From there you can update the text field you use for displaying the size.
What about:
CGSize window_size = my_window.frame.size;
NSSize myNSWindowSize = [ [ myNSWindow contentView ] frame ].size;
...should be what you're looking for. fbrereto's suggestion is what you should use if you want the size including the NSWindow's title bar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With