Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSWindow resize indicator not visible

How do I show resize indicators for an NSWindow without Titlebar?


I created a new Xcode project(for Mac app) with storyboard. I just disabled the checkbox Title Bar in Appearance(It hides the Title bar of NSwindow).

The strange thing was, after disabling the TitleBar, NSWindow was not showing resize indicators while mouse was above the window edges. Although if I drag at edges it was resizing.

I guess this is a bug, because if the window can be resized by dragging the mouse over edges, it must show the resize indicators.


image

As it can be seen in the image, the resize indicators are seen after user drags the window, but many users would think that since there is no resize indicator, the window is not resizable.

like image 465
Kaunteya Avatar asked Oct 16 '15 10:10

Kaunteya


2 Answers

I have not checked this, but you could set the resize indicators manually. I think I would add four NSTrackingAreas to the windows contentView subclass (one for each side of the window, only few pixels in height/width). In the mouseEntered() method, create a new NSCursor object for the appropriate mouse position. Remember that the position could change, so use the mouseMoved() method as well. On mouseExited() reset the cursor.

Again, I have not tried this, but it should work.

PS: Don't forget to file a radar on this ;)

like image 55
mangerlahn Avatar answered Sep 21 '22 17:09

mangerlahn


I've fixed this issue by subclassing NSWindow and overriding canBecomeKeyWindow to return YES:

#import "MyWindow.h"

@implementation MyWindow

- (BOOL)canBecomeKeyWindow {
    return YES;
}

@end

Not updating resize cursors in this case looks like Apple bug. Documentation states "The value of canBecomeKeyWindow property is YES if the window has a title bar or a resize bar, or NO otherwise.", so I expect that canBecomeKeyWindow will return YES for resizable window. But it doesn't.

UPD: Checked on 10.10.5. Hopefully, you will have same behaviour on 10.11.

like image 37
Borys Verebskyi Avatar answered Sep 20 '22 17:09

Borys Verebskyi