0
votes

I want to create a NSView subclass which contains a resize triangle/grippy at the bottom right corner of the view. The idea is that from IB you can set this as the class for any custom view and it will automatically convert it into a resizable area. For example you can put a NSTextField into this custom view, assign the bounds and that should make the text field resizable.

Before I proceed doing this, is there something that already has this behaviour? If not, what will be the best way approach the problem?

1

1 Answers

0
votes

I don't know of anything that does this for you automatically. There are things to consider (z-order and collisions) beyond just making an arbitrary control user-resizable.

That said, I'll assume you know how to draw a basic grip in a custom view (if not, read the basic Cocoa Drawing Guide and post specific questions if you get stuck). Beyond that, you'll need to investigate the Mouse Handling Events section of the Cocoa Event Handling Guide and implement mouse dragging behavior from inside a tracking area (which you'll create for the same area in which you drew your grip - you can also set a resize cursor for the area). Dragging from here will set the view's frame accordingly.