简体   繁体   中英

NSWindow resize control covered by NSView

I have an NSView subclass sized to fit a regular NSWindow window (right to the edges).

The view draws a background color, and when the app runs, it covers up the standard window resize control in the bottom right hand corner. You can still resize the window by dragging the corner.

If I resize my view so it doesn't quite go to the edge of the window, it's clear that the resize control is being drawn, but being overlapped by my view.

Anyone know of a way to fix this? Will I have to draw the resize control myself?

Here's a screenshot showing what I mean.

You will either have to draw the grip yourself or knock out the lower-right corner of your background. Given that your view is flush with the edges of the window, I'd just draw it myself and be done with it.

Only trouble is I believe you'll have to handle drag-to-resize yourself if you do it this way (don't quote me, though). If so, you'll have to create an NSTrackingArea for that corner and handle drags in that area as window frame changes (size and origin).

So I got it working by creating a layer with an image of the handle, and positioning it in the bottom right corner of the layer of the view. I don't have to implement the dragging myself - it just works.

Use a backed layer versus a hosted layer. A hosted layer is typically for something really custom and applied to a borderless window in my experience.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM